Child pages
  • Array property type

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
titleDO it like this
var newPropertyValue = [ 1, 2, 3 ];
// here you assign a new array to the property
elements.myCustomComponent.myArrayProperty = newPropertyValue;
// here you update the reference that you want to use later in code with the 'watched' new value
newPropertyValue = elements.myCustomComponent.myArrayProperty;
;
(...then later on, maybe during another event handler execution...)

// this modification will be detected because it's using the new 'watched' value you got from elements.myCustomComponent.myArrayProperty after it was assigned - and the change will be sent to the browser
newPropertyValue[1] = 5; 
Code Block
languagejs
titleOR like this
var newPropertyValue = [ 1, 2, 3 ];
// here you assign a new array to the property
elements.myCustomComponent.myArrayProperty = newPropertyValue;

(...then later on, maybe during another event handler execution...)

// this modification will be detected because it's using the property directly not through 'newPropertyValue'
elements.myCustomComponent.myArrayProperty[1] = 5; 
Code Block
languagejs
titleDON'T do it like this
var newPropertyValue = {};
// here you assign a new array to the property
elements.myCustomComponent.myArrayProperty = newPropertyValue;

(...then later on, maybe during another event handler execution...)

// this will modify the value in newPropertyValue but myCustomComponent.myArrayProperty will not be aware of that to send changes to client/browser
newPropertyValue[1] = 5; 

...