-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallApply.js
30 lines (27 loc) · 1 KB
/
callApply.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
/**
*
*/
let countries = ['Moldova', 'Ukraine'];
let otherCountries = ['USA', 'Japan'];
countries.push.apply(countries, otherCountries);
// countries.push(...otherCountries); // ['Moldova', 'Ukraine', 'USA', 'Japan']
// countries.push(countries, otherCountries); // [ 'Moldova', 'Ukraine', [Circular], [ 'USA', 'Japan' ] ]
console.log(countries); // => ['Moldova', 'Ukraine', 'USA', 'Japan']
///////////////////////////////////////
class King {
constructor(name, country) {
this.name = name;
this.country = country;
}
getDescription() {
/**
* @url https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
*/
return `${this.name} leads ${this.country}`;
// return this.name + " leads " + this.country;
}
}
var details = ['Alexander the Great', 'Greece'];
var Alexander = new King(...details);
Alexander.getDescription(); // => 'Alexander the Great leads Greece'
console.log(Alexander.getDescription())