-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.js
65 lines (49 loc) · 1.46 KB
/
notes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*Based on how data is stored and accessed - datatypes are of two types: Primitive and Non-Primitive
Primitive: String, Number, Boolean, BigInt, null, undefined, Symbol
//Dynamically type Programming Language JS
//Reference(Non-Primitive)
// Array, Objects, Functions
*/
let bigNumber = 1488564864548848454n;
let heros = ["Shik", "Shak"];
let myObj = {
name:"HArsh",
age:19,
//Curly ke andar jitna vo object hai, any datatype
}
const meraFun = function () {
console.log("hello there \n");
}
meraFun();
console.log(typeof myObj);
/* TypeOfDatatype
undefined => undefined
Null => object
Sab Non-Primitive ka Type "Object" hai
specially function ka datatype 'Object Function' hai. return me function me ayega
*/
//Symbol
const id = Symbol('2140')
const anotherId = Symbol('2140')
console.log(id === anotherId); //Both are different even though same jaa rha
/*
Two types of Memory:
Stack(Primitive){Copy milti} and Heap(Non-Primitive){Original Value change, reference milta}
*/
let name = "HIii"
let realName = name
realName = "Harsh"
console.log(name);
console.log(realName);
//Change in Copy
let seniorOfficerOne = {
email:"[email protected]",
crew:"StrawHats",
}
let srOfficerOne = seniorOfficerOne
srOfficerOne.email = "[email protected]"
console.log(seniorOfficerOne);
console.log(seniorOfficerOne.email);
console.log(srOfficerOne.email);
//Change in reference i.e. Address
// let and const have local scope in curlys while var have global scope in curlys