People seem to hate the with () construct in javascript, but anyway ...
function f(){return {a:1, b:2};} with(f()) { alert(a);//1 } // or function combine(propertyNames, values) { var o = {}; for (var i=0; i<propertyNames.length; i++) { o[propertyNames[i]] = values[i]; } return o; } with (combine(['a', 'b'], [1, 2])) { alert(b);//2 }
source share