cachaito
7/18/2016 - 1:40 PM

Passing and assigning in function parameter

var obj = {};
var prop = 'aaa';

function foo(arg) {
  return console.log('passed: ' + arg);
}

// foo(obj[prop] = 'bbb') --> just passing result of the assignment expression, not an object
// foo(((obj[prop] = 'bbb'), obj)); //works
foo(obj, obj[prop] = 'bbb');