Primitives and Objects in JavaScript
// nn bb ss u -> Primitive Data types in JS
//n = null, n = number, b = boolean, b = bigInt, s = string, s = symbol, u = undefined
let a = null;
let b = 345;
let c = true; //can also be false
let d = BigInt("567") + BigInt("3");
let e = "Harry"
let f = Symbol("I am a nice symbol")
let g = undefined
let h
console.log(a, b, c, d, e, f, g, h)
console.log(typeof a, typeof b, typeof c, typeof d, typeof e, typeof f, typeof g, typeof h)
console.log(typeof d)
//Objects in JS
//Objects are Non Primitive Data types in JS
const item = {
"Harry": true,
"Shubh": false,
"Lovish": 67,
"Rohan": undefined
}
console.log(item["Harry"])
console.log(item["sdf"])
OUTPUT :
null 345 true 570n Harry Symbol(I am a nice symbol) undefined undefined
object number boolean bigint string symbol undefined undefined
bigint
true
undefined
Comments
Post a Comment