Object methods Flashcards
1
Q
How to create a new object method by setting object value key
A
function toObject(keyValuePair) { var key = keyValuePair[0]; var value = keyValuePair[1]; var obj = {}; obj[key] = value; return obj; }
How to create a new object method by setting object value key
function toObject(keyValuePair) { var key = keyValuePair[0]; var value = keyValuePair[1]; var obj = {}; obj[key] = value; return obj; }