mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-13 19:08:03 -05:00
[arrays] use Array#slice to copy an array. Fixes #41
This commit is contained in:
@@ -142,7 +142,7 @@
|
||||
someStack.push('abracadabra');
|
||||
```
|
||||
|
||||
- When you need to copy an array use Array() constructor. [jsPerf](http://jsperf.com/converting-arguments-to-an-array/7)
|
||||
- When you need to copy an array use Array#slice. [jsPerf](http://jsperf.com/converting-arguments-to-an-array/7)
|
||||
|
||||
```javascript
|
||||
var len = items.length,
|
||||
@@ -155,7 +155,7 @@
|
||||
}
|
||||
|
||||
// good
|
||||
itemsCopy = Array.apply(null, items);
|
||||
itemsCopy = Array.prototype.slice.call(items);
|
||||
```
|
||||
|
||||
**[[⬆]](#TOC)**
|
||||
|
||||
Reference in New Issue
Block a user