javascript how to change switch the keys and values in a object code example
Example 1: swap key value object javascript
function swap(json){
var ret = {};
for(var key in json){
ret[json[key]] = key;
}
return ret;
}
Example 2: js change key value in object
var object = { boo:true, baa:5 };
console.log(object);
function change() {
object.boo = false;
object.baa++;
};
change();
console.log(object);
//Hope this helps!