mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Use new operator to invoke the array.constructor.
This commit is contained in:
@@ -10,7 +10,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
|
|||||||
*/
|
*/
|
||||||
function initCloneArray(array) {
|
function initCloneArray(array) {
|
||||||
const length = array.length
|
const length = array.length
|
||||||
const result = array.constructor(length)
|
const result = new array.constructor(length)
|
||||||
|
|
||||||
// Add properties assigned by `RegExp#exec`.
|
// Add properties assigned by `RegExp#exec`.
|
||||||
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user