What are the data types available in JavaScript?
In JavaScript data types is an important concept that helps to operate on variables,JavaScript supports mainly two different kinds of data types-
- Primitives
- Objects
1. Primitives Data Type
It supports six data types that’s are given below.
- Boolean: It represents only true or false based on condition.
- Number: It can be written with or without decimals. Example
var num1 = 32;
- String: It is used to store texts and inside of either double or single quotes. Example
var str_one = 'Best Interview Question';
- Null: It is "nothing" but supposed to be something that does not exist.
- Undefined: It has no value but variable is exists. Example
var MyVariable_1;
console.log(MyVariable_1); // undefined - Symbol: It is new in ES6. It is an immutable data type that have unique value.Example :
const BestInterviewQuestion = Symbol(‘BestInterviewQuestion’);
2. Objects Data Type
It is a type of not primitive data Type. It is a collection of properties and these properties are stored in key and value pairs.
BY Best Interview Question ON 18 Mar 2020