This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let first = [1,2,3,4]; | |
let second = [...first]; | |
console.log(second); //[1,2,3,4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const first ={name: "john"}; | |
const second ={age: 30}; | |
const coord ={...first,...second}; | |
console.log(coord); // {name: "john",age: 30}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let country =["USA","CANADA","GERMANY"]; | |
let [usa,...other] = country; | |
console.log(usa); //USA | |
console.log(other); //["CANADA","GERMANY"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let country =["USA","CANADA","GERMANY"]; | |
let [usa,...other] = country; | |
console.log(usa); //USA | |
console.log(other); //["CANADA","GERMANY"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum(x,y,z) { | |
return x + y + z; | |
} | |
const numbers =[1,2,3]; | |
console.log(...numbers); //1 2 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum(x,y,z) { | |
let sum = x + y + z; | |
return sum; | |
} | |
console.log(sum(5,5,5,5)); //15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sum = 0; | |
function myFunction() { | |
for (var i in arguments) { | |
sum += arguments[i]; | |
} | |
return sum; | |
} | |
console.log(myFunction(5, ...[5, 5, 5])); //20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction() { | |
for (var i in arguments) { | |
console.log(arguments[i]); | |
} | |
} | |
var params =[10,15] | |
console.log(myFunction(5,...params); // 5 10 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const x = new Date(...[2019, 15, 6]); | |
console.log(x); //script.js:39 Mon Apr 06 2020 00:00:00 GMT+0600 (Bangladesh Standard Time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function abc(...values) { | |
return values; | |
} | |
console.log(abc(1,2,3)); //[1,2,3]; |