-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataTypes-Summary.js
More file actions
63 lines (41 loc) · 1.47 KB
/
dataTypes-Summary.js
File metadata and controls
63 lines (41 loc) · 1.47 KB
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
// Two types of data types in JavaScript:
// 1. Primitive data types
// 2. Non-primitive data types
// Primitive data types-------------------------
// 7 primitive data types
// 1. String,number,boolean,null,undefined,bigint,symbol
// Javascript is a dynamically typed language
// Reference data types-------------------------(Non-primitive data types)
// Array,object,functions
// If you ever want to master javascript - do objects and browser evennts
const id = Symbol("121");
const bignum = 266542546245n;
// Array,object,function
const heros = ["shaktiman", "naagraj", "doga"];
let heroObj = {
name: "shaktiman",
power: "light",
};
const myFunc = function () {
console.log("hello JS");
};
console.log(typeof heroObj);
console.log(typeof bignum);
// *******************************************************
// Stack (Primitive data types) and Heap (Non-primitive data types)
// stack give copy, heap give reference(orignal value chanege hota hai)
let ytName = "codehere";
let anotherYtName = ytName; // here we are only passing the copy values
anotherYtName = "codethere"; // so even we chnage it our reference giving ytName dont chamge
console.log(ytName);
console.log(anotherYtName);
// Goes into Heap
let user = {
id: 1,
name: "harshit",
upiId: "harshit@okaxis",
};
let admin = user; // here we are passing the reference of user object
console.log(user);
admin.name = "codewithharshit"; // so even we change it our reference giving user also chamge
console.log(user);