-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathES6Feature.js
More file actions
110 lines (88 loc) · 2.05 KB
/
ES6Feature.js
File metadata and controls
110 lines (88 loc) · 2.05 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// let const
// default parameters
function checkDefault(a = 1, b = 2, c = 3) {
console.log("a=>", a);
console.log("b=>", b);
console.log("c=>", c);
}
checkDefault(5, 6, 7);
// template literals and multiline string
const stringLiteral = `vishal
vcishal
znmxbc
nzmxc s
bns dch sd
`;
function generateTemplate(name = "User", mobile) {
// const emailTemplate = 'Hey ' + user + "your number" + mobile + 'has been recharge successfully';
const emailTemplate = `Hey ${name} "your number ${mobile} has been recharge successfully`;
console.log(emailTemplate);
}
generateTemplate("adsd", 9278787486);
generateTemplate();
generateTemplate();
// Arrow functions
// Promises
// block scoping
// Object Destructuring
var object = {
clg: "Chris chruch university",
cty: "Kanpur",
brnc: "CSE",
};
// const college = object.collegeName;
// const city = object.cityName;
// const branch = object.branch;
// Object destructring , given alias , by default
const { clg: college, cty: city, brnc: branchCode, regNo = "12345" } = object;
console.log("college", college);
console.log("cityName", city);
console.log("city", branchCode);
console.log("regNo", regNo);
function positionName() {
return ["ADAM", "Lalu", "Kamal"];
}
const data = positionName();
const [firstName, secondName, lastName] = data;
console.log(firstName, secondName, lastName);
// destuctring for nested object
// spread department->block->name(departMentBlockName)
let student = {
name: "Adam",
lasdtName: "Gil",
address: {
local: {
city: "UK",
pincode: "2392321", // => 1235667
},
},
department: {
block: {
name: "36A",
},
},
hostel: {
name: "BH3",
},
collegeName: {
name: "LPU",
},
};
const departMentBlockName = student.department.block.name;
const HostelName = student.hostel.name;
const t = { a: 123, b: 235 };
const { a, b } = t;
const {
address: {
local: { pincode },
},
} = student;
console.log(pincode);
student = {
...student,
...student.address,
local: {
pincode: 1235667,
},
};
console.log(student);