English 中文(简体)
JavaScript 中的“ 未定义的 x 1” 是什么?
原标题:What is "undefined x 1" in JavaScript?
最佳回答

这似乎是在数组(和array-类似 天体)中显示非初始化索引的铬新方式 :

> Array(100)
[undefined × 100]

这肯定比打印[未定义、未定义、未定义、...] 或任何之前的版本都好。

虽然,如果只有一个 undered 值,它们可以降低 x 1

问题回答

新的铬版本使用 empty 而不是 un defered 来使差异更加明确。

例如,在 DevTools 控制台输入 [、未定义、] 的结果如下:

▼(4) [empty × 2, undefined, empty]
   2: undefined
   length: 4
  ▶__proto__: Array(0)

Google Chrome似乎选择显示 < a href=> http://books.google.com/ books? id= 6TAODddEIrgC& pg=PA144&dq=sparse%20ary;dq=sparse%20arvive&sourg=bl&ots=obbbbppIWPuUG&sig=16mc9YQ6QNeatyTFZ9YP704Mf5xSA&hl=en&sa=Xamp;ei=NDFUPrDJOOO8A3S4GODGg&ved=0CC4QA#v=onepage&q=sparse%20ray%20defitave&f=false"nfolfol=" "nofolf" spartraction "re" < a < a > < a > 使用此 un defredeed > n < a it.

var arr = new Array(2);
console.log(arr);

var arr2 = [];
arr2[3] = 123;
console.log(arr2);

var arr3 = [,,,];
console.log(arr3)

var arr4 = [,];
console.log(arr4)

var arr5 = [undefined, undefined]
console.log(arr5)

var arr6 = [undefined]
console.log(arr6)

arr1至arr4是所有稀少的阵列,而rr5和ar6则不是。

[undefined × 2] 
[undefined × 3, 123] 
[undefined × 3] 
[undefined × 1] 
[undefined, undefined] 
[undefined] 

注意细数组的 [未定义 x1]

自从您删除了元素后, 以下的元素 : < a href=" "http://books.google.com/ books? id= 6TAODdEIxrgC& lpg=PA144& ots=obbbpIWPuUG&dq=sparse% 20arry% 20definitive& pg=pA146#v=onepage&q=sparse% 20arry% 20definitive& f=false" rel="no folter"。 如果您从一个阵列中删除元素, 数组的数组就会变得稀疏。

下面是它的外观, 输入这个代码到 染色体代谢工具控制台: --

arr = new Array(4);
arr[2] = "adf";
console.log(arr);    // [undefined × 2, "adf", undefined × 1]

请参阅由 *2 代表的前两个连续两个“ 未定义” “ 未定义”, 以显示有连续两个连续两个“ 未定义” 。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签