javascript数组在创建时不为空 [英] javascript array is not empty on creation

查看:71
本文介绍了javascript数组在创建时不为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我目前正在使用重型javascript的网络应用程序。在一个

的函数中,使用var admin_types =

new Array();创建一个简单的数组。此数组不为空,长度为0但

包含一个名为clone的元素。和价值


function(){var copy = {}; for(var i in this){var value = this [i];

try {if(value!= null&& typeof(value)==" object"&&值!=

window&&!value.nodeType){value.clone = Object.clone; copy [i] =

value.clone(); } else {copy [i] = value; catch(e){copy [i] =

value;返回副本; }


为什么要创建这个元素?奇怪的是我使用了很多

的数组,这是唯一拥有该元素的数据。


i在firefox 1.0中尝试过这个,即5.5和mozilla 1.7.1和元素

在所有这些元素的数组中...

任何帮助将不胜感激

Rusty

Hi,

im currently working on a web app which uses heavy javascript. in one
of the functions, a simple array is created using "var admin_types =
new Array();". This array is not empty, it has a length of 0 but
contains one element with the name "clone" and the value

function () { var copy = {}; for (var i in this) { var value = this[i];
try { if (value != null && typeof (value) == "object" && value !=
window && !value.nodeType) { value.clone = Object.clone; copy[i] =
value.clone(); } else { copy[i] = value; } } catch (e) { copy[i] =
value; } } return copy; }

why does this element get created?? The weird thing is that i use a lot
of arrays and this is the only one that has that element.

i tried this in firefox 1.0, ie 5.5 and mozilla 1.7.1 and the element
is in the array for all of them...
any help would be appreciated
Rusty

推荐答案

我刚刚发现网络应用程序中的所有数组都有

" clone"元件。当我在创建数组的头部创建一个带有javascript

函数的简单html页面时,它不包含

" clone"元素......

i just discovered that all of the arrays in the web app have the
"clone" element. When i created a simple html page with a javascript
function in the head that creates an array, it does not contain a
"clone" element...


rusty说:

我刚发现web app中的所有数组拥有
克隆元件。当我在创建数组的头部创建一个带有javascript
函数的简单html页面时,它不包含
clone element ...

i just discovered that all of the arrays in the web app have the
"clone" element. When i created a simple html page with a javascript
function in the head that creates an array, it does not contain a
"clone" element...




它不是数组的元素,它是Array对象的一种方法。



It''s not an element of the array, it''s a method of the Array object.


如果它是一个方法,为什么你可以使用admin_types [''clone'']来访问它?

if its a method, why can u access it using admin_types[''clone''] ??


这篇关于javascript数组在创建时不为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆