Variables and assignment

Variables should be declared with the var keyword. Any variable that is declared outside of a function, or any variable that is used without being declared, is a global variable, and global variables are a big problem; their place in default JavaScript is one of the major design flaws.

When there was a major public relations push for Java, JavaScript was named to run on Java's coattails, and certain decisions were made to make JavaScript code look like Java. These decisions were unfortunate. JavaScript is formally a C-like language and its most recent common ancestor with Java or C# is C, not C++ or Java. JavaScript has been described as being like Scheme in C's clothing. Lisp is a syntax associated with a family of languages ...

Get React: Building Modern Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.