Skip navigation

Creating variables in often referred to as “declaring” variables. var statement used to declare variables.

Interesting part is, you don’t need to declare a variable to use it. Just start using it like

age=25;

After some time, you realize your mistake and redeclare it like
var age;

You may expect, now the value of age is 0 ….

But still the age is 25 !!!


age = 25;
var age;
alert(age); // 25

Above order is perfect in JavaScript.

Great POWER comes with great RESPONSIBILITY.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: