Demo 1
Create new Javascript file named demo1.js. This file contains code demo as below:
let cde = ['c', 'd', 'e'];
let scale = ['a', 'b', ...cde, 'f', 'g'];
console.log(scale);
Run Demo 1
Use node demo1.js statement run code demo
[ 'a', 'b', 'c', 'd', 'e', 'f', 'g' ]
Demo 2
Create new Javascript file named demo2.js. This file contains code demo as below:
const android = ['galaxy s7', 'nokia 1020', 'xiaomi mi5'];
const iphone = ['iphone 7 ', 'iphone8', 'iphone9'];
const phones = [...android, ...iphone, 'nokia phone 100'];
console.log(phones);
Run Demo 2
Use node demo2.js statement run code demo
[ 'galaxy s7',
'nokia 1020',
'xiaomi mi5',
'iphone 7 ',
'iphone8',
'iphone9',
'nokia phone 100' ]