DataTypes Notebook
DataTypes
JavaScript has 8 data types.
- Basic 8 types: String, Number, Bigint, Boolean, Undefined, Null, Symbol, Object
- Object types: objects, arrays, dates, maps, sets, intarrays, floatarrays, promises, and more.
IN [9]
let x = 16 + "Volvo"; // OR "Volvo" + 16;
let y = 16 + 4 + "Volvo";
let z = "Volvo" + 16 + 4;
console.log("x: " + x + " and y: " + y + " and z: " + z); IN [12]
// Dynamic types
let x; // Now x is undefined
x = 5; // Now x is a Number
x = "John"; // Now x is a String
console.log(typeof x); IN [14]
// Exponentials
let y = 123e5; // 12300000
let z = 123e-5; // 0.00123Javascript numbers are always one type: double (64-bit floating point).
IN [17]
let x = BigInt("123456789012345678901234567890");
console.log(typeof x + " " + x + " length: " + x.toString().length); IN [18]
typeof 3.14 IN [21]
// car = undefined;
console.log(typeof undefined); IN [ ]