JavaScript Data Types
JavaScript has 8 Datatypes
String
Number
Bigint
Boolean
Undefined
Null
Symbol
Object
The Object Datatype
The object data type can contain both built-in objects, and user defined
objects:
Built-in object types can be:
objects, arrays, dates, maps, sets, intarrays, floatarrays, promises, and
more.
let x=10
[Link](typeof x);
output:
let x='10'
[Link](typeof x);
output:
let x="10"
[Link](typeof x);
output
let x="Kumar Nishant"
[Link](typeof x);
output
let x=10.23
[Link](typeof x);
Output:
let x=true;
[Link](typeof x);
output
let x;
[Link](typeof x);
output
let student={name:'kumar' ,city:'Mumbai'};
[Link](typeof student);
output
let student=['kumar','nishant','Ramesh']
[Link](typeof student);
output
JavaScript Types are Dynamic
JavaScript has dynamic types. This means that the same variable can be
used to hold different data types:
Example:
let x=10;
[Link](x);
x='kumar';
[Link](x);
output:
let x="Hello how are You Kumar?";
[Link](x);
let y="Hello how are you 'Kumar'";
[Link](y);
let z='Hello how are your "Kumar"';
[Link](z);
output:
let x=BigInt("9874563214569877");
[Link](typeof x);
output
let x='Nishant'+10;
[Link](x);
output:
let x='Nishant'+10+20;
[Link](x);
let x=10+20+'Nishant';
[Link](x);
output:
let x=null;
[Link](x);
[Link](typeof x);
output:
const s=Symbol();
[Link](typeof s);
output:
const s=Symbol('hello');
[Link]([Link]);
output