This file contains hidden or 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 sampleArr = [1, 9, 17, -3, 7, 89, 40, 100, 121, 8]; | |
const maxValue = Math.max(...sampleArr); | |
const minValue = Math.min(...sampleArr); | |
console.log(maxValue); //121 | |
console.log(minValue); //-3 |
This file contains hidden or 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 addThreeNumbers(a, b, c) { | |
return a + b + c; | |
} | |
let sampleArr = [1, 2, 3]; | |
console.log(addThreeNumbers(...sampleArr)); //6 |
This file contains hidden or 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 sampleArr = [1, 2, 3, 4, 5]; | |
var x = sampleArr[0], | |
y = sampleArr[1]; | |
var temp = [x, y]; | |
y = temp[0]; | |
x = temp[1]; | |
var subArr; | |
x = sampleArr[0]; | |
y = sampleArr[1]; |
This file contains hidden or 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 sampleArr = [1, 2, 3, 4, 5]; | |
let [x, y] = sampleArr; | |
[y, x] = [x, y]; | |
let subArr; | |
[x, y, ...subArr] = sampleArr; | |
console.log(subArr); //[3, 4, 5]; |
NewerOlder