Running node v17.9.1 (npm v8.11.0)
[Function: bound call]
/project/node_modules/core-js/internals/a-callable.js:10
throw new $TypeError(tryToString(argument) + ' is not a function');
^
TypeError: 1 is not a function
at module.exports (/project/node_modules/core-js/internals/a-callable.js:10:9)
at module.exports (/project/node_modules/core-js/internals/function-bind-context.js:10:3)
at /project/node_modules/core-js/internals/array-iteration-from-last.js:13:25
at Object.findLastIndex (/project/node_modules/core-js/modules/es.array.find-last-index.js:10:12)
at Object.<anonymous> (/project/example.js:7:13)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
Node.js v17.9.1
but in node 18 ~ 20, code works as intended, following ecma-262
Running node v18.19.0 (npm v10.2.3)
[Function: bound call]
/project/example.js:6
const array = { length: { valueOf: function () { throw 42; } }, 1: 1, 2: 2 };
^
42
(Use `node --trace-uncaught ...` to show where the exception was thrown)
Node.js v18.19.0
I think this error can be fixed by changing orders of those lines in array-iteration-from-last.js (and array-iteration.js)
This code works different in node 17 and node 18:
In node 17, TypeError is caught
but in node 18 ~ 20, code works as intended, following ecma-262
I think this error can be fixed by changing orders of those lines in
array-iteration-from-last.js
(andarray-iteration.js
)https://github.com/zloirock/core-js/blob/c44bfe9ee82aec23e6ed04a09cd7e06a49e1f70d/packages/core-js/internals/array-iteration-from-last.js#L13-L14
https://github.com/zloirock/core-js/blob/c44bfe9ee82aec23e6ed04a09cd7e06a49e1f70d/packages/core-js/internals/array-iteration.js#L23-L24