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

"types & grammar": cover what Array(3) is actually doing #69

Closed
getify opened this issue Feb 17, 2014 · 2 comments
Closed

"types & grammar": cover what Array(3) is actually doing #69

getify opened this issue Feb 17, 2014 · 2 comments
Assignees

Comments

@getify
Copy link
Owner

getify commented Feb 17, 2014

big wtf: Array(3) is production something more like [].length = 3 than [undefined,undefined,undefined]. insane.

@getify getify self-assigned this Feb 17, 2014
@JakeChampion
Copy link

I decided to see what happens if you copy the array into itself. This was the result:

var a = Array(3);
console.log(a); // [undefined × 3]
a[1] = a; // [undefined × 1, Array[3], undefined × 1]
a[1][1] // [undefined × 1, Array[3], undefined × 1]
a[1][1][1] // [undefined × 1, Array[3], undefined × 1]
a[1][1][1][1][1][1][1][1][1][1][1] // [undefined × 1, Array[3], undefined × 1]

This seems to create an infinite series of nested arrays, I have no idea why though. Any ideas?

I used the Chrome DevTools to test this out.

@cirocosta
Copy link

@JakeChampion, This is Circular Reference. In NodeJS it simplifies to [Circular]. So, doing that with node you'll get:

a[1] = a;    // [ , [Circular]  ,]

@getify getify changed the title for "types & grammar", cover what Array(3) is actually doing "types & grammar": cover what Array(3) is actually doing Mar 31, 2014
@getify getify closed this as completed Jul 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants