What are variables and how we use them in Jquery?

Variables can contain any value like text, numbers, data (such as "arrays" and "objects"), even code (in the form of "functions"). We declare a variable using a var statement:

var myName = "Reshu";

Variable names can be just about anything, as long as they do not begin with a number and do not include a hyphen.
You can define one variable per statement:

  1. var a = 1;
  2. var b = "two";
You can also define multiple variables in a single statement, by separating them with commas:
1. var a = 1,
    b = "two";

Once you have assigned a value to a variable, you can use that variable whenever you want to get access to the value you stored.

Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*