array Class
Index
Methods
removeAtRemoves the array item at the specified index.fastRemoveAtRemoves the array item at the specified index. It's faster but the order of the array will be changed.removeRemoves the first occurrence of a specific object from the array.fastRemoveRemoves the first occurrence of a specific object from the array. It's faster but the order of the array will be changed.verifyTypeVerify array's TyperemoveArrayRemoves from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.appendObjectsAtInserts some objects at indexindexOfExact 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!containsDetermines whether the array contains a specific value.copyCopy an array's item to a new array (its performance is better than Array.slice)
Details
Methods
removeAt
Removes the array item at the specified index.
| meta | description |
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:654 |
Parameters
- array Any
- index Number
fastRemoveAt
Removes the array item at the specified index. It's faster but the order of the array will be changed.
| meta | description |
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:664 |
Parameters
- array Any
- index Number
remove
Removes the first occurrence of a specific object from the array.
| meta | description |
|---|---|
| Returns | Boolean |
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:680 |
Parameters
- array Any
- value Any
fastRemove
Removes the first occurrence of a specific object from the array. It's faster but the order of the array will be changed.
| meta | description |
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:698 |
Parameters
- array Any
- value Number
verifyType
Verify array's Type
| meta | description |
|---|---|
| Returns | Boolean |
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:713 |
Parameters
removeArray
Removes from array all values in minusArr. For each Value in minusArr, the first matching instance in array will be removed.
| meta | description |
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:732 |
Parameters
appendObjectsAt
Inserts some objects at index
| meta | description |
|---|---|
| Returns | Array |
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:744 |
Parameters
indexOf
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!
| meta | description |
|---|---|
| Returns | Number |
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:757 |
Parameters
- searchElement Any Element to locate in the array.
- fromIndex Number The index to start the search at
contains
Determines whether the array contains a specific value.
| meta | description |
|---|---|
| Returns | Boolean |
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:769 |
Parameters
- array Any
- value Any
copy
Copy an array's item to a new array (its performance is better than Array.slice)
| meta | description |
|---|---|
| Returns | Array |
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/js.js:780 |
Parameters
- array Array