pass in javascript code example

Example 1: pass keyword in javascript

// leave it blank there is no pass keyword ie. blank space means PASS

Example 2: javascript function variable arguments

function foo() {
  for (var i = 0; i < arguments.length; i++) {
    console.log(arguments[i]);
  }
}

foo(1,2,3);
//1
//2
//3

Example 3: javascript pass by value

function func(obj) {
  obj = JSON.parse(JSON.stringify(obj)); //If too slow, replace with other method of deep cloning
  obj.a += 10;
  return obj.a;
}

var myObj = {a: 5};
func(myObj); //Returns 15 and myObj.a is still 5