Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
342 views
in Technique[技术] by (71.8m points)

arrays - What is "undefined x 1" in JavaScript?

I'm doing some small experiments based on this blog entry.

I am doing this research in Google Chrome's debugger and here comes the hard part.

What the heck is this?!

I get the fact that I can't delete local variables (since they are not object attributes). I get that I can 'read out' all of the parameters passed to a function from the array called 'arguments'. I even get it that I can't delete and array's element, only achieve to have array[0] have a value of undefined.

Can somebody explain to me what undefined x 1 means on the embedded image?

And when I overwrite the function foo to return the arguments[0], then I get the usual and 'normal' undefined.

This is only an experiment, but seems interresting, does anybody know what undefined x 1 refers to?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That seems to be Chrome's new way of displaying uninitialized indexes in arrays (and array-like objects):

> Array(100)
[undefined × 100]

Which is certainly better than printing [undefined, undefined, undefined,...] or however it was before.

Although, if there is only one undefined value, they could drop the x 1.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...