-
Notifications
You must be signed in to change notification settings - Fork 0
/
ES6.js
71 lines (54 loc) · 1.1 KB
/
ES6.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
66
67
68
69
70
71
//SPREAD
let num1 = [1, 2, 3];
let num2 = [...num1, 4, 5, 6];
let num3 = [num1, 4, 5, 6];
console.log(num2);
console.log(num3);
function add(a, b, c) {
console.log("sum: " + (a + b + c));
}
add(...num1);
// REST
let X = [1, 2, 3];
let Y = [4, 5, X];
let Z = [4, 5, 6, ...X];
console.log(Y);
console.log(Z);
//TEMPLATE STRINGS
let myString = `Hi, i'm Ayesha
and i'm practicing JS`;
console.log(myString);
//ENHANCED OBJECT LITERALS
// let speed = 60;
// let model = "Audi";
// let myCarr = {
// speed,
// model,
// drive() {
// console.log("i'm driving");
// },
// getSpeed() {
// console.log("my speed is " + this.speed);
// }
// };
// console.log(`${myCarr.drive()}`);
//ARROW FUNCTIONS
let myNewCar = {
speed: 60,
model: "audi",
drive() {
console.log("i'm driving");
},
getSpeed() {
speeD = () => {
console.log("my speed is " + this.speed);
};
speeD();
}
};
myNewCar.getSpeed();
//SETS
let mySet = new Set();
mySet.add("ayesha", "ali", "farhan", "waris");
mySet.size;
mySet.has("ayesha");