Javascript 替换对象中的数组项

Javascript 替换对象中的数组项,javascript,arrays,Javascript,Arrays,我有一个像下面这样的物体。在propertymixed数组中,我有一个数组,我想用Chu数组项替换数组 var myObject = { propertyString: "this is a string", propertyAnotherString: "this is another string", propertyMixedArray: [{"item 1"},{ "item 2"}, {"item 3"}], propertyObject: { so

我有一个像下面这样的物体。在propertymixed数组中,我有一个数组,我想用Chu数组项替换数组

var myObject = {
    propertyString: "this is a string",
    propertyAnotherString: "this is another string",
    propertyMixedArray: [{"item 1"},{ "item 2"}, {"item 3"}],  
    propertyObject: { someProperty: "and so on..." }
};

ch_array =[{"new val1"},{ "new val 2"}, {"newval3"}];

var myObject = {
    propertyString: "this is a string",
    propertyAnotherString: "this is another string",
    propertyMixedArray: [{"new val1"},{ "new val 2"}, {"newval3"}],  
    propertyObject: { someProperty: "and so on..." }
};

只需将属性指定给新数组:

myObject.propertyMixedArray = ch_array;

myObject.propertyMixedArray=Chu数组
?简单<代码>myObject.propertyMixeArray=ch_数组这些不是正确的JSassignments@nnnnnn
Chu数组=[{“新值1”}、{“新值2”}、{“新值3”}]
真的吗?@Redu-是的,我在评论之后立即意识到了这一点,这就是为什么我立即删除了那条评论。