scope

Displaying 1 - 1 of 1

JavaScript variable scoping compared to C

For the most part, JavaScript looks like a C-like language in syntax. Lines end (optionally) with semicolons, conditional expressions are in parentheses (e.g. if (a == 1)), and blocks are surrounded by braces. But there are some huge differences in both syntax and behavior. JavaScript is weakly typed, and its object oriented programming is prototype-based, much different from C++/Java. And for someone who understands how memory for C variables is allocated, JavaScript has a number of surprises in its variables and variable scoping.

  1. There's no block-level scoping,
  2. ...