Skip to content

Instantly share code, notes, and snippets.

@pradeeprjth
Created August 24, 2021 12:03
Show Gist options
  • Save pradeeprjth/8d6778c1330d1829983247b21fb40f3e to your computer and use it in GitHub Desktop.
Save pradeeprjth/8d6778c1330d1829983247b21fb40f3e to your computer and use it in GitHub Desktop.
alert( Math.max(3, 5, 1) ); // 5
let arr = [3, 5, 1];
alert( Math.max(arr) );
let arr = [3, 5, 1];
alert( Math.max(...arr) ); // 5 (spread turns array into a list of arguments)
// --------------------------------------------
function sum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(sum(...numbers));
// expected output: 6
console.log(sum.apply(null, numbers));
// expected output: 6
// --------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment