i have two questions:
1) is it possible to delete any value in jsarray or only the last on with the pop method?
2) how can i remove or delete a value from jsarray? does somebody can post an example.
something like this here
public JsArray<MyObject> myObjects = JavaScriptObject.createArray().cast();
myObjects.push(new MyObject("Good"));
myObjects.push(new MyObject("morning"));
myObjects.push(new MyObject("people"));
myObjects.delete(1);
thx a lot!
Arrays in JavaScript are sparse, so you cannot, for example, remove an object from it and have all the following be moved up to lower indices (like you’d have in Java with a
Listfor instance); at least not with some remove method.Using only GWT Java, you can set the value at a specific index to
null, but that’s it.Using JSNI, you can delete it (almost equivalent to setting it to
undefined:delete myObjects[1]) or you can remove it: