Skip to content

Instantly share code, notes, and snippets.

View shahab570's full-sized avatar

MD SHAHAB UDDIN shahab570

View GitHub Profile
let first = [1,2,3,4];
let second = [...first];
console.log(second); //[1,2,3,4]
const first ={name: "john"};
const second ={age: 30};
const coord ={...first,...second};
console.log(coord); // {name: "john",age: 30};
let country =["USA","CANADA","GERMANY"];
let [usa,...other] = country;
console.log(usa); //USA
console.log(other); //["CANADA","GERMANY"];
let country =["USA","CANADA","GERMANY"];
let [usa,...other] = country;
console.log(usa); //USA
console.log(other); //["CANADA","GERMANY"];
function sum(x,y,z) {
return x + y + z;
}
const numbers =[1,2,3];
console.log(...numbers); //1 2 3
function sum(x,y,z) {
let sum = x + y + z;
return sum;
}
console.log(sum(5,5,5,5)); //15
var sum = 0;
function myFunction() {
for (var i in arguments) {
sum += arguments[i];
}
return sum;
}
console.log(myFunction(5, ...[5, 5, 5])); //20
function myFunction() {
for (var i in arguments) {
console.log(arguments[i]);
}
}
var params =[10,15]
console.log(myFunction(5,...params); // 5 10 15
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)
function abc(...values) {
return values;
}
console.log(abc(1,2,3)); //[1,2,3];