Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var id = (x) => x, x = id(...[1,2,3]); typeof x; #365

Closed
drsm opened this issue Jan 11, 2021 · 3 comments
Closed

var id = (x) => x, x = id(...[1,2,3]); typeof x; #365

drsm opened this issue Jan 11, 2021 · 3 comments
Labels

Comments

@drsm
Copy link
Contributor

drsm commented Jan 11, 2021

>> var id = (x) => x, x = id(...[1,2,3]); typeof x;
'object'

it doesn't fail like it should.

@277hz
Copy link

277hz commented Jun 2, 2021

Could you explain for me how or why it should fail?
One difference I see when executing with e.g. Chrome:

var id = (x) => x, x = id(...[1,2,3]); console.log(typeof x, x);
number 1

Firefox:

var id = (x) => x, x = id(...[1,2,3]); console.log(typeof x, x);
number 1

njs:

interactive njs 0.5.3

>> var id = (x) => x, x = id(...[1,2,3]); console.log(typeof x, x);
object [1,2,3]

interactive njs 0.6.0

>> var id = (x) => x, x = id(...[1,2,3]); console.log(typeof x, x);
object [1,2,3]

Edit:
Maybe because spread is not supported at all?

interactive njs 0.6.0

>> [...[1,2,3]]
[

]

@drsm
Copy link
Contributor Author

drsm commented Jun 2, 2021

@277hz
Hi!
It should fail 'cause it's not supported #78 :)

@277hz
Copy link

277hz commented Jun 3, 2021

@drsm See #78.

>> ((a, b, c, d) => console.log(a, b, c, d))(...[1, 3], ...[2, 4]);
1 3 2 4

>> ((a, b, c, d) => console.log(a, b, c, d))(...[1, 3], [2, 4]);
1 3 [2,4] undefined

>> ((a, b, c, d) => console.log(a, b, c, d))(...[1, 3], [2], 4]);
1 3 [2] 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants