about 9 years ago
In javascript,There are variables in which we can store the values. We declare a variable with the var keyword:
The variables have different data types in javascript.
Variable | Explanation | Example |
---|---|---|
String | It takes "A string of text". To verify that the variable is a string, we have to enclose it in quote marks. | var myVariable = 'IPhone'; |
Number | It takes "A number". Numbers never have quotes around them. | var myVariable = 50; |
Boolean | It takes "A True/False value". These true and false are special keywords in Javascript and don't need quotes. | var myVariable = true/False; |
Array | A structure that allows you to store multiple values in one single reference. | var myVariable = [1,'Bob','Steve',10]; Refer to each member of the array like this: myVariable[0], myVariable[1], etc. |
Object | Basically, It takes anything. Everything in JavaScript is an object, and can be stored in a variable.Always Keep this in mind as you learn js. | var myVariable = document.querySelector('h3'); All of the above examples too. |
Can you help out the community by solving one of the following Javascript problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)