Cocos Creator API

1.5.x

Cocos Creator is the game engine for the future.

array static

Module: js
Parent Module: js

Methods

removeAt
(
  • array
  • index
)

Removes the array item at the specified index.

name type description
array Any
index Number

fastRemoveAt
(
  • array
  • index
)

Removes the array item at the specified index. It's faster but the order of the array will be changed.

name type description
array Any
index Number

remove
(
  • array
  • value
)
Boolean

Removes the first occurrence of a specific object from the array.

name type description
array Any
value Any

returns:

type: Boolean

fastRemove
(
  • array
  • value
)

Removes the first occurrence of a specific object from the array. It's faster but the order of the array will be changed.

name type description
array Any
value Number

verifyType
(
  • array
  • type
)
Boolean

Verify array's Type

name type description
array array
type Function

returns:

type: Boolean

removeArray
(
  • array
  • minusArr
)

Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.

name type description
array Array

Source Array

minusArr Array

minus Array

appendObjectsAt
(
  • array
  • addObjs
  • index
)
Array

Inserts some objects at index

name type description
array Array
addObjs Array
index Number

returns:

type: Array

indexOf
(
  • searchElement
  • [fromIndex =0]
)
Number

Exact same function as Array.prototype.indexOf. HACK: ugliy hack for Baidu mobile browser compatibility, stupid Baidu guys modify Array.prototype.indexOf for all pages loaded, their version changes strict comparison to non-strict comparison, it also ignores the second parameter of the original API, and this will cause event handler enter infinite loop. Baidu developers, if you ever see this documentation, here is the standard: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf Seriously !

name type description
searchElement Any

Element to locate in the array.

fromIndex optional Number 0

The index to start the search at

returns:

type: Number

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

contains
(
  • array
  • value
)
Boolean

Determines whether the array contains a specific value.

name type description
array Any
value Any

returns:

type: Boolean

copy
(
  • array
)
Array

Copy an array's item to a new array (its performance is better than Array.slice)

name type description
array Array

returns:

type: Array

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index