scala.scalajs.js

Array

class Array[A] extends Object

Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed. Since an array's size length grow or shrink at any time, JavaScript arrays are not guaranteed to be dense. In general, these are convenient characteristics; but if these features are not desirable for your particular use, you might consider using typed arrays.

MDN

To construct a new array with uninitialized elements, use the constructor of this class. To construct a new array with specified elements, as if you used the array literal syntax in JavaScript, use the Array.apply method instead.

A

Type of the elements of the array

Annotations
@RawJSType()
Linear Supertypes
Object, Any, AnyRef, scala.Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Array
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Array(arrayLength: Number)

    Creates a new array with the given length.

    Creates a new array with the given length.

    arrayLength

    Initial length of the array.

  2. new Array()

    Creates a new array of length 0.

Value Members

  1. final def !=(arg0: scala.Any): scala.Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. def +(that: String): String

    Definition Classes
    Any
  4. final def ==(arg0: scala.Any): scala.Boolean

    Definition Classes
    AnyRef → Any
  5. def apply(index: Number): A

    Access the element at the given index.

    Access the element at the given index.

    Annotations
    @JSBracketAccess()
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def concat(item: A, items: A*): Array[A]

    concat creates a new array consisting of the elements in the this object on which it is called, followed in order by, for each argument, the elements of that argument (if the argument is an array) or the argument itself (if the argument is not an array).

    concat creates a new array consisting of the elements in the this object on which it is called, followed in order by, for each argument, the elements of that argument (if the argument is an array) or the argument itself (if the argument is not an array).

    MDN

  9. def concat(items: Array[A]*): Array[A]

    concat creates a new array consisting of the elements in the this object on which it is called, followed in order by, for each argument, the elements of that argument (if the argument is an array) or the argument itself (if the argument is not an array).

    concat creates a new array consisting of the elements in the this object on which it is called, followed in order by, for each argument, the elements of that argument (if the argument is an array) or the argument itself (if the argument is not an array).

    MDN

  10. final def eq(arg0: AnyRef): scala.Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: scala.Any): scala.Boolean

    Definition Classes
    AnyRef → Any
  12. def every(callbackfn: Function3[A, Number, Array[A], Boolean]): Boolean

  13. def every[T](callbackfn: ThisFunction3[T, A, Number, Array[A], Boolean], thisArg: T): Boolean

    The every method executes the provided callback function once for each element present in the array until it finds one where callback returns a falsy value (a value that becomes false when converted to a Boolean).

    The every method executes the provided callback function once for each element present in the array until it finds one where callback returns a falsy value (a value that becomes false when converted to a Boolean). If such an element is found, the every method immediately returns false. Otherwise, if callback returned a true value for all elements, every will return true. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.

    callback is invoked with three arguments:

    - the value of the element - the index of the element - and the Array object being traversed.

    If a thisObject parameter is provided to every, it will be used as the this for each invocation of the callback. If it is not provided, or is null, the global object associated with callback is used instead.

    every does not mutate the array on which it is called.

    every acts like the "for all" quantifier in mathematics. In particular, for an empty array, it returns true. (It is vacuously true that all elements of the empty set satisfy any given condition.)

    MDN

  14. def filter(callbackfn: Function1[A, Boolean]): Array[A]

  15. def filter(callbackfn: Function2[A, Number, Boolean]): Array[A]

  16. def filter(callbackfn: Function3[A, Number, Array[A], Boolean]): Array[A]

  17. def filter[T](callbackfn: ThisFunction3[T, A, Number, Array[A], Boolean], thisArg: T): Array[A]

    filter calls a provided callback function once for each element in an array, and constructs a new array of all the values for which callback returns a true value.

    filter calls a provided callback function once for each element in an array, and constructs a new array of all the values for which callback returns a true value. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. Array elements which do not pass the callback test are simply skipped, and are not included in the new array.

    callback is invoked with three arguments:

    - the value of the element - the index of the element - the Array object being traversed

    If a thisObject parameter is provided to filter, it will be used as the this for each invocation of the callback. If it is not provided, or is null, the global object associated with callback is used instead.

    filter does not mutate the array on which it is called.

    MDN

  18. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def forEach(callbackfn: Function1[A, _]): Unit

  20. def forEach(callbackfn: Function2[A, Number, _]): Unit

  21. def forEach(callbackfn: Function3[A, Number, Array[A], _]): Unit

  22. def forEach[T](callbackfn: ThisFunction3[T, A, Number, Array[A], _], thisArg: T): Unit

    forEach executes the provided callback once for each element of the array with an assigned value.

    forEach executes the provided callback once for each element of the array with an assigned value. It is not invoked for indexes which have been deleted or which have been initialized to undefined.

    callback is invoked with three arguments:

    - the element value - the element index - the array being traversed

    If a thisArg parameter is provided to forEach, it will be used as the this value for each callback invocation as if callback.call(thisArg, element, index, array) was called. If thisArg is undefined or null, the this value within the function depends on whether the function is in strict mode or not (passed value if in strict mode, global object if in non-strict mode).

    MDN

  23. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  24. def hasOwnProperty(v: String): Boolean

    Every object descended from Object inherits the hasOwnProperty method.

    Every object descended from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the in operator, this method does not check down the object's prototype chain.

    MDN

    Definition Classes
    Object
  25. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  26. def indexOf(searchElement: A): Number

  27. def indexOf(searchElement: A, fromIndex: Number): Number

    The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.

    The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.

    MDN

  28. final def isInstanceOf[T0]: scala.Boolean

    Definition Classes
    Any
  29. def isPrototypeOf(v: Object): Boolean

    The isPrototypeOf mehtod allows you to check whether or not an object exists within another object's prototype chain.

    The isPrototypeOf mehtod allows you to check whether or not an object exists within another object's prototype chain.

    MDN

    Definition Classes
    Object
  30. def join(seperator: String = ","): String

    The join() method joins all elements of an array into a string.

    The join() method joins all elements of an array into a string.

    separator Specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma.

  31. def lastIndexOf(searchElement: A): Number

  32. def lastIndexOf(searchElement: A, fromIndex: Number): Number

    The lastIndexOf() method returns the last index at which a given element can be found in the array, or -1 if it is not present.

    The lastIndexOf() method returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex.

    MDN

  33. def length: Number

    Length of the array.

  34. def map[B](callbackfn: Function1[A, B]): Array[B]

  35. def map[B](callbackfn: Function2[A, Number, B]): Array[B]

  36. def map[B](callbackfn: Function3[A, Number, Array[A], B]): Array[B]

  37. def map[B, T](callbackfn: ThisFunction3[T, A, Number, Array[A], B], thisArg: T): Array[B]

    map calls a provided callback function once for each element in an array, in order, and constructs a new array from the results.

    map calls a provided callback function once for each element in an array, in order, and constructs a new array from the results. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.

    callback is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.

    If a thisArg parameter is provided to map, it will be used as the this for each invocation of the callback. If it is not provided, or is null, the global object associated with callback is used instead.

    map does not mutate the array on which it is called.

    MDN

  38. final def ne(arg0: AnyRef): scala.Boolean

    Definition Classes
    AnyRef
  39. final def notify(): Unit

    Definition Classes
    AnyRef
  40. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  41. def pop(): A

    The pop() method removes the last element from an array and returns that element.

    The pop() method removes the last element from an array and returns that element.

    MDN

  42. def propertyIsEnumerable(v: String): Boolean

    Every object has a propertyIsEnumerable method.

    Every object has a propertyIsEnumerable method. This method can determine whether the specified property in an object can be enumerated by a for...in loop, with the exception of properties inherited through the prototype chain. If the object does not have the specified property, this method returns false.

    MDN

    Definition Classes
    Object
  43. def push(items: A*): Number

    The push() method mutates an array by appending the given elements and returning the new length of the array.

    The push() method mutates an array by appending the given elements and returning the new length of the array.

    MDN

  44. def reduce[B](callbackfn: Function2[B, A, B]): B

  45. def reduce[B](callbackfn: Function3[B, A, Number, B]): B

  46. def reduce[B](callbackfn: Function4[B, A, Number, Array[A], B]): B

  47. def reduce[B](callbackfn: Function2[B, A, B], initialValue: B): B

  48. def reduce[B](callbackfn: Function3[B, A, Number, B], initialValue: B): B

  49. def reduce[B](callbackfn: Function4[B, A, Number, Array[A], B], initialValue: B): B

    reduce executes the callback function once for each element present in the array, excluding holes in the array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring.

    reduce executes the callback function once for each element present in the array, excluding holes in the array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring.

    The first time the callback is called, previousValue and currentValue can be one of two values. If initialValue is provided in the call to reduce, then previousValue will be equal to initialValue and currentValue will be equal to the first value in the array. If no initialValue was provided, then previousValue will be equal to the first value in the array and currentValue will be equal to the second.

    MDN

  50. def reduceRight[B](callbackfn: Function2[B, A, B]): B

  51. def reduceRight[B](callbackfn: Function3[B, A, Number, B]): B

  52. def reduceRight[B](callbackfn: Function4[B, A, Number, Array[A], B]): B

  53. def reduceRight[B](callbackfn: Function2[B, A, B], initialValue: B): B

  54. def reduceRight[B](callbackfn: Function3[B, A, Number, B], initialValue: B): B

  55. def reduceRight[B](callbackfn: Function4[B, A, Number, Array[A], B], initialValue: B): B

    reduceRight executes the callback function once for each element present in the array, excluding holes in the array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring.

    reduceRight executes the callback function once for each element present in the array, excluding holes in the array, receiving four arguments: the initial value (or value from the previous callback call), the value of the current element, the current index, and the array over which iteration is occurring.

    MDN

  56. def reverse(): Array[A]

    The reverse() method reverses an array in place.

    The reverse() method reverses an array in place. The first array element becomes the last and the last becomes the first.

    MDN

  57. def shift(): A

    The shift() method removes the first element from an array and returns that element.

    The shift() method removes the first element from an array and returns that element. This method changes the length of the array.

    MDN

  58. def slice(start: Number): Array[A]

  59. def slice(start: Number, end: Number): Array[A]

    The slice() method returns a shallow copy of a portion of an array.

    The slice() method returns a shallow copy of a portion of an array.

    MDN

  60. def some(callbackfn: Function1[A, Boolean]): Boolean

  61. def some(callbackfn: Function2[A, Number, Boolean]): Boolean

  62. def some(callbackfn: Function3[A, Number, Array[A], Boolean]): Boolean

  63. def some[T](callbackfn: ThisFunction3[T, A, Number, Array[A], Boolean], thisArg: T): Boolean

    some executes the callback function once for each element present in the array until it finds one where callback returns a true value.

    some executes the callback function once for each element present in the array until it finds one where callback returns a true value. If such an element is found, some immediately returns true. Otherwise, some returns false. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.

    callback is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.

    If a thisObject parameter is provided to some, it will be used as the this for each invocation of the callback. If it is not provided, or is null, the global object associated with callback is used instead.

    some does not mutate the array on which it is called.

    MDN

  64. def sort(compareFn: Function2[A, A, Number] = ???): Array[A]

    The sort() method sorts the elements of an array in place and returns the array.

    The sort() method sorts the elements of an array in place and returns the array. The sort is not necessarily stable. The default sort order is lexicographic (not numeric).

    If compareFunction is not supplied, elements are sorted by converting them to strings and comparing strings in lexicographic ("dictionary" or "telephone book," not numerical) order. For example, "80" comes before "9" in lexicographic order, but in a numeric sort 9 comes before 80.

    MDN

  65. def splice(index: Number, deleteCount: Number, items: A*): Array[A]

    The splice() method changes the content of an array, adding new elements while removing old elements.

    The splice() method changes the content of an array, adding new elements while removing old elements.

    MDN

  66. def splice(index: Number): Array[A]

    The splice() method changes the content of an array, adding new elements while removing old elements.

    The splice() method changes the content of an array, adding new elements while removing old elements.

    MDN

  67. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  68. def toLocaleString(): String

    Definition Classes
    Object
  69. def toString(): java.lang.String

    Definition Classes
    AnyRef → Any
  70. def unary_!(): Boolean

    Definition Classes
    Any
  71. def unshift(items: A*): Number

    The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

    The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

    MDN

  72. def update(index: Number, value: A): Unit

    Set the element at the given index.

    Set the element at the given index.

    Annotations
    @JSBracketAccess()
  73. def valueOf(): Any

    Definition Classes
    Object
  74. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  75. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  76. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from scala.Any

Ungrouped