如何使用函数在javascript中向对象添加键/值对

时间:2016-09-23 18:22:00

标签: javascript

var myObject = {
    key1: "value1",
    key2: "value2",
};

function addToMyObject(item) {
    myObject.item;
    console.log(item + " has been added to your object.");
    console.log(myObject);
}

addToMyObject(key3 = "value3");

我知道我可以将我的对象转换为数组,但是我可以将它转换为对象吗?

0 个答案:

没有答案