JavaScript Closure

The code below creates closure where function y() remembers all of its surrounding states and lexical scope even when it’s parent function x() goes out of scope. Suppose we return function y (not the invocation of it, but the function itself) and assign it to var bob. When we run bob() million lines later, it… Continue reading JavaScript Closure

Semicolon; or not in Javascript

Semicolon or not to semicolon?Quick answer: pick a convention and stick to it. Neither is absolutely wrong nor absolutely right. ECMAScript specification even states it can be written without semicolons. ECMAScript programs can be written in a style with very few semicolons by relying on automatic semicolon insertion. Their words, not mine. As long as… Continue reading Semicolon; or not in Javascript