2016-06-24 13 views
-1

私は以下のようなオブジェクトを持っています。 propertymixed配列では、私は配列をch_array項目で置き換える配列があります。オブジェクト内の配列項目を置換する

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..." } 
}; 
+2

'myObject.propertyMixedArray = ch_array'? – trincot

+0

シンプル... 'myObject.propertyMixedArray = ch_array;' –

+0

これは適切なJS割り当てではありません – Redu

答えて

1

ただ、新しい配列にプロパティを割り当てる:

myObject.propertyMixedArray = ch_array; 
関連する問題