T - the type of the array items@JsType(isNative=true,
name="Array",
namespace="<global>")
public class JsArray<T>
extends Object
JsCollections.array() to create an appropriate instance.| Modifier | Constructor and Description |
|---|---|
protected |
JsArray()
Should not be directly created.
|
| Modifier and Type | Method and Description |
|---|---|
JsArray<T> |
clear()
Clears the array.
|
void |
forEach(JsCollections.ForEachCallback<T> callback)
Invokes the provided callback for each value in this array.
|
T |
get(int index)
Gets the item at the given index.
|
boolean |
isEmpty()
Checks if the array is empty (length == 0).
|
int |
length()
Gets the current length of this array.
|
int |
push(T... values)
Adds items to the end of this array.
|
int |
pushArray(JsArray<? extends T> values)
Adds items to the end of this array.
|
T |
remove(int index)
Removes the item at the given index.
|
boolean |
remove(T toRemove)
Removes the given item from the array.
|
void |
set(int index,
T value)
Sets the item at the given index.
|
T |
shift()
Removes and returns the first value from the array.
|
JsArray<T> |
splice(int index,
int remove,
T... add)
Removes and adds a number of items at the given index.
|
JsArray<T> |
spliceArray(int index,
int remove,
JsArray<? extends T> add)
Removes and adds a number of items at the given index.
|
@JsOverlay public final T get(int index)
return array[index] in JavaScript.index - the index to get@JsOverlay
public final void set(int index,
T value)
array[index] = value in JavaScript.index - the index to setvalue - the value to setpublic int push(T... values)
values - the new values to add@JsOverlay public final int pushArray(JsArray<? extends T> values)
values - the new values to add@JsProperty(name="length") public int length()
@JsOverlay public final JsArray<T> spliceArray(int index, int remove, JsArray<? extends T> add)
index - the index at which do do the operationremove - the number of items to removeadd - new items to addpublic JsArray<T> splice(int index, int remove, T... add)
index - the index at which do do the operationremove - the number of items to removeadd - new items to add@JsOverlay public final T remove(int index)
index - the index to remove@JsOverlay public final boolean isEmpty()
@JsOverlay public final boolean remove(T toRemove)
toRemove - the item to removetrue if the item was found and removed from the
array, false otherwisepublic T shift()
public void forEach(JsCollections.ForEachCallback<T> callback)
callback - the callback to invoke for each valueCopyright © 2000–2026 Vaadin Ltd. All rights reserved.