2016-06-24 2 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;