-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTypes.js
More file actions
42 lines (28 loc) · 1.08 KB
/
DataTypes.js
File metadata and controls
42 lines (28 loc) · 1.08 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
// Primitive Data Types
let num = 42;
let str = "Hello, World!";
let bool = false;
let undef;
let nul = null;
console.log(num, typeof num); //[42 , 'number]
console.log(str, typeof str); //['Hello world!' , 'string]
console.log(bool, typeof bool); //[false , 'boolean]
console.log(undef, typeof undef); //[undefined , 'undefined']
console.log(nul, typeof nul); //[null . 'object]
// Non - Primitive Data Types
// Object Types
let person = {
name: "Alice",
age: 30,
isEmployed: true
};
console.log(person, typeof person); //[ { name: "Alice", age: 30, isEmployed: true } , 'object]
// Array Types but it type is object
let numbers = [1, 2, 3, 4, 5];
console.log(numbers, typeof numbers); //[ [1, 2, 3, 4, 5] , 'object']
// Function Types
function greet(name) {
return "Hello, " + name + "!";
}
console.log(greet, typeof greet); //['function']
console.log(greet("Alice")); //'Hello , Alice!'