Ways convert Pesude-Array to Array becomes unsafe
console.log(Array.from("❤").length === 2)
for (const char of "❤") {
console.log(char); // only one ❤
}
Original Typescript Code
const a = [...new Array(8).keys()];
console.log(a);
After compiling Typescript to JavaScript
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var a = __spreadArray([], new Array(8).keys(), true);
console.log(a);
there is nothing in the console
Array.from(new Array(10).keys())