-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatatypesinJavascript.js
More file actions
40 lines (27 loc) · 941 Bytes
/
Copy pathDatatypesinJavascript.js
File metadata and controls
40 lines (27 loc) · 941 Bytes
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
//Primitive Datatypes
//7 Primitive Datatypes - String, boolean, number,null, BigInt, undefined, symbol
//Non Primitive Datatypes (Reference Variable)
//Object, functions, Array
const id = Symbol('123')
const anotherid = Symbol('123')
console.log(id === anotherid); //output will be false because Symbols in JavaScript are unique and immutable primitive values
const bigInt = 94857345080984n; //The 'n' suffix tells JavaScript to treat it as BigInt
//Arrays
const fruits = ["Apple", "Banana", "Grapes"]
//Objects
let myObj = {} // Create empty object
myObj.name = "Rutuja" // Use equals (=) when assigning after creation
myObj.age = 21
// OR
myObj["name"] = "Rutuja"
myObj["age"] = 21
let person = {
personname : "Rutuja" ,
personage : 22
}
//Functions
const myFunction = function () {
console.log("Hello World!");
}
//return type of all non primitive types are object
console.log = (typeof myFunction);