Javascript

Variables and Literals in JavaScript

Literals

Literals are constant values that represents various data types like numeric, string, array , boolean etc and can be assigned to variables.

JavaScript Variables

Variables are containers for holding data values.

‘var’, ‘let’, ‘const’ are the reserved keywords to declare variables in JavaScript.

We can assign the value to variables using equal to(=) operator at the time of declaration or anytime before using it.

JavaScript variables are case sensitive.

JavaScript variables are loosely typed.

Syntax :

var <variable-name>

var <variable-name>  =  <value>

Rules for variable name construction:

Names can contain letters, digits, underscore and dollar sign.

There is no limit to the length of variable name.

Names can begin with letter , $ or _ sign

We cannot use reserve words as variable names

Adding Comments in JavaScript

Single-Line Comment- Using  //

Multi-Line Comments -Using  /* */

To watch detail explaination, please refer the video below:

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s