What’s the point of the var keyword? [duplicate]

Without the var keyword it becomes possible to accidentally create a new variable when you had actually intended to use an already existing variable. e.g.

name = "fred";
   ...
Name = "barney"; // whoops! we meant to reuse name

Leave a Comment