Use new operator to invoke the array.constructor.

This commit is contained in:
John-David Dalton
2017-02-05 22:44:38 -08:00
parent 5219385eb2
commit 23c0bc0e7a

View File

@@ -10,7 +10,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
*/
function initCloneArray(array) {
const length = array.length
const result = array.constructor(length)
const result = new array.constructor(length)
// Add properties assigned by `RegExp#exec`.
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {