JS-Interpreter icon indicating copy to clipboard operation
JS-Interpreter copied to clipboard

new Date(number) throws TypeError: Bind must be called on a function

Open jer-sen opened this issue 3 years ago • 5 comments

Hello,

When calling new Date(1234) I get this error:

TypeError: Bind must be called on a function

I would expect just to get a Date with valueOf returning 1234.

jer-sen avatar Dec 05 '21 13:12 jer-sen

Can't recreate. My steps:

  • Go to https://neil.fraser.name/software/JS-Interpreter/
  • Replace code with: alert(new Date(1234))
  • Press Parse then press Run.

Actual result: An alert with "Wed Dec 31 1969 16:00:01 GMT-0800 (Pacific Standard Time)"

What steps are you using to get this error?

NeilFraser avatar Dec 05 '21 20:12 NeilFraser

Just install js-interpreter npm module with npm install js-interpreter, then run node command in a terminal and then this JS code: (new (require('js-interpreter'))("new Date(1234)")).run();. You should get the error TypeError: Bind must be called on a function.

jer-sen avatar Dec 06 '21 08:12 jer-sen

Got it. This bug was previously raised and fixed in #218. Looks like the js-interpreter package you are using needs to be updated. Not sure whom to ping regarding that.

NeilFraser avatar Dec 23 '21 07:12 NeilFraser

The npm package seems abandoned :( https://www.npmjs.com/package/js-interpreter

It is downloaded 3100 times a week. You don't want to publish your project on npm?

jer-sen avatar Dec 23 '21 19:12 jer-sen

@jer-sen @NeilFraser I have updated the package, sorry if this has been misleading, but the NPM package points to my repo which has this one as a submodule and publishes the package from there, I'll keep an eye on issues here in case the package related requests come up here.

aminmarashi avatar Aug 23 '22 17:08 aminmarashi