JavaScript is a dynamic or loosely typed language, means we don't need to specify type of the variable because it is dynamically specified by JavaScript engine based on the type of input. We just need to use var or let keyword to create variable. There are basically two types of data type in JavaScript, which are given below-
Primitive Data Types:- There are besically five types of primitive data type in JavaScript, which are given below-
Data Types | Description |
---|---|
String | It represents any string (example "hello"). |
Number | It represents any numeric value (example 777). |
Boolean | It represents boolean value (example true or false). |
Undefined | It represents undefined value. |
Null | It represents null value. |
Non-primitive or Reference Data Types There are besically two types of non-primitive data type in JavaScript, which are given below-
Data Types | Description |
---|---|
Array | It represents multiple values of same or different data types in a single variable. |
Object | It represents instance by which we can access members. |
JavaScript keywords are reserved words, which we cannot use to name the variables or functions. There are total of 63 keywords which JavaSscript provides to the programmers.
Keywords | |||
---|---|---|---|
abstract | arguments | boolean | break |
byte | case | catch | char |
const | continue | class* | debugger |
default | delete | do | double |
else | eval | enum* | export* |
extends* | false | final | finally |
float | for | function | goto |
if | implements | in | instanceof |
int | interface | import* | let |
long | native | new | null |
package | private | protected | public |
return | short | static | switch |
synchronized | super* | this | throw |
throws | transient | true | try |
typeof | var | void | volatile |
while | with | yield | - |
Keywords, which are marked with * symbols are the new keywords in ECMAScript 5 and 6.