-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes6.js
40 lines (37 loc) · 972 Bytes
/
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
const years = [1990, 1991, 1992];
var ages = years.map(function (el) {
return 2016 - el;
})
console.log('&&&&&&&&&&&&&&', ages);
var ages1 = years.map(el => 2019 - el);
console.log('++++++++++++', ages1);
//old
function addF(a, b, c) {
return a + b + c;
}
var ag = [18, 32, 45];
var sum = addF.apply(null, ag);
console.log('------------', sum);
// new
const sum1 = addF(...ag);
console.log('////////////', sum1);
const fName = ['chethan', 'ravi', 'sachin'];
const lName = ['babu', 'naik', 'omprakash'];
console.log('---***names***---', [...fName, ...lName]);
// ES6 class
class Person {
constructor(name, yob, job) {
this.name = name,
this.yob = yob,
this.job = job
}
calc() {
const age = new Date().getFullYear - this.yob;;
console.log(age);
}
static greeting() {
console.log('Hey there');
}
}
const chethan = new Person('chethan', 1993, 'Dev');
console.log('%#$#$#^#', chethan);