[ javascript ] … Three dots

Function argumentation

function countArguments(...args) {
  return args.length;
}
// get the number of arguments
countArguments('welcome', 'to', 'Earth'); // => 3

array

// destructure an array
let otherSeasons, autumn;
[autumn, ...otherSeasons] = ['autumn', 'winter'];
otherSeasons // => ['winter']

Working with array

let cold = ['autumn', 'winter'];
let warm = ['spring', 'summer'];
// construct an array
[...cold, ...warm] // => ['autumn', 'winter', 'spring', 'summer']
// function arguments from an array
cold.push(...warm);
cold // => ['autumn', 'winter', 'spring', 'summer']

Math.max

Math.max(1, 3, 2);

// or

var array1 = [1, 3, 2];

Math.max(...array1);

 

ref : https://dmitripavlutin.com/how-three-dots-changed-javascript/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s