arithmetic operation in JS code example
Example 1: js calculate
answer_Add = 5 + 1; //answer = 6
answer_Sub = 5 - 1; //answer = 4
answer_Multi = 5 * 5; //answer = 25
answer_Divi = 10 / 2; //answer = 5
Total = answer_Add + answer_Sub + answer_Multi + answer_Divi;
Example 2: javascript ... operator
//The operator ... is part of the array destructuring.
//It's used to extract info from arrays to single variables.
//The operator ... means "the rest of the array".
var [head, ...tail] = ["Hello", "I" , "am", "Sarah"];
console.log(head);//"Hello"
console.log(tail);//["I", "am", "Sarah"]
//It can be used to pass an array as a list of function arguments
let a = [2,3,4];
Math.max(a) //--> NaN
Math.max(...a) //--> 4