Input Code
const assert = require('assert')
let arr = new Array(3);
/*
* or
* let arr = [,,,];
*/
let arr2 = [...arr];
assert(arr2.hasOwnProperty(0));
.babelrc
{
"presets": ["@babel/preset-env"]
}
Expected Behavior
No error will be thrown
Current Behavior
var assert = require('assert');
var arr = new Array(3);
var arr2 = arr.concat();
assert(arr2.hasOwnProperty(0));
AssertionError [ERR_ASSERTION]: false == true
Possible Solution
Since empty array (e.g., new Array, or [,,,]) has difference (weird?) structure.
Add _toConsumableArray and check properties when compiling rest operator.
Context
The following code will be incorrect.
let tmp = new Array(100);
let series = [...tmp].map((_,i) => i);
// [0, 1, 2, 3, ..., 99]
Your Environment
| software |
version(s) |
| Babel |
7.0.0-beta.38 |
| node |
8.8.1 |
| npm |
- |
| Operating System |
- |
Input Code
.babelrc
Expected Behavior
No error will be thrown
Current Behavior
Possible Solution
Since empty array (e.g.,
new Array, or[,,,]) has difference (weird?) structure.Add
_toConsumableArrayand check properties when compiling rest operator.Context
The following code will be incorrect.
Your Environment