arithmetic operator in javascript code example

Example 1: modulus js

console.log(10%3);
//returns 1 (the remainder of 10/3)

Example 2: javascript Arithmetic operators

var additionOutput = 2 + 2; //addition
var subtractionOutput = 2 - 2; //subtraction
var multiplcationOutput = 2 * 2; //multiplcation
var divisionOutput = 2 / 2; //division
var exponentiation = 2**2; // Exponentiation
var modulus = 5 % 2; // Modulus (Remainder)
var unaryOperator = 1; 
++unaryOperator; // Unary Operator Increment // ++ , --

Example 3: 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