2次迭代

编程入门 行业动态 更新时间:2024-10-21 06:05:52
本文介绍了2次迭代 - 不同的结果 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好, 有谁能告诉我为什么这两组代码会给出不同的结果? for(J in Next){ < action> } < function> for(J = 0; J< Next 。长度; ++ J){ <与上述动作相同> } <与上述功能相同> 我想更改第二个版本,以便它给出与第一个版本相同的 结果。 任意想法好吗?! 干杯 Geoff

Hello, Can anyone tell me why these 2 sets of code give different results? for (J in Next) { <action> } <function> for (J=0;J<Next.length;++J) { <same action as above> } <same function as above> I would like to change the second version so that it gives the same results as the first one. Any ideas please?! Cheers Geoff

推荐答案

Geoff Cox< gc ** @ freeuk.notcomwrites: Geoff Cox <gc**@freeuk.notcomwrites: 您好, 任何人都可以告诉为什么这两组代码给出了不同的结果? for(J in Next){ < action> } < function> for(J = 0; J< Next.length; ++ J){ <与上述相同的动作> } <与上面相同的功能> 我想更改第二个版本,以便它给出相同的 结果作为第一个。 有什么想法吗?! Hello, Can anyone tell me why these 2 sets of code give different results? for (J in Next) { <action> } <function> for (J=0;J<Next.length;++J) { <same action as above> } <same function as above> I would like to change the second version so that it gives the same results as the first one. Any ideas please?!

他们完全不一样。使用第一个版本。 - Joost Diepenmaat |博客: joost.zeekat.nl/ |工作: zeekat.nl/

They''re not the same at all. Use the first version. -- Joost Diepenmaat | blog: joost.zeekat.nl/ | work: zeekat.nl/

2008年4月19日星期六23:05:10 +0200,Joost Diepenmaat< jo *** @ zeekat.nl> 写道: On Sat, 19 Apr 2008 23:05:10 +0200, Joost Diepenmaat <jo***@zeekat.nl> wrote: > Geoff Cox< gc ** @ freeuk.notcomwrites: >Geoff Cox <gc**@freeuk.notcomwrites: >你好, 可以有谁告诉我为什么这两组代码给出了不同的结果? for(J in Next){< action> } < function> for(J = 0; J< Next.length; ++ J){<与上述相同的动作> } <与上述相同的功能> ; 我想改变第二个版本,以便它给出与第一个版本相同的结果。 请问任何想法?! >Hello,Can anyone tell me why these 2 sets of code give different results?for (J in Next) {<action>}<function> for (J=0;J<Next.length;++J) {<same action as above>}<same function as above>I would like to change the second version so that it gives the sameresults as the first one.Any ideas please?!

他们根本不一样。使用第一个版本。

They''re not the same at all. Use the first version.

Joost, 我很乐意这样做,但它会导致与prototype.js发生冲突 库我被告知for / in进程可以处理属性 对象而不是某些Javscript实现中的元素... 你能告诉我它有什么区别吗? 干杯 Geoff

Joost, I would love to do so but it causes a conflict with the prototype.js library as I''m told that the for/in process can deal with properties of objects rather than elements in some Javscript implementations... Can you tell me what the difference is/are? Cheers Geoff

4月20日凌晨1点02分,Geoff Cox< g ... @ freeuk.notcomwrote: On Apr 20, 1:02 am, Geoff Cox <g...@freeuk.notcomwrote: 你好, 谁能告诉我为什么这两组代码给出不同的结果? for(J in Next){ Hello, Can anyone tell me why these 2 sets of code give different results? for (J in Next) {

枚举Next对象的属性,包括但不限于 数组元素 - 给定Next instanceof Array。 var Next = [1 ,2,3]; Next.foo =''bar; for(var p in Next){ //将找到四个元素: // 1,2,3, ''bar'' }

enumerates properties of Next object including but not limited by array elements - given that Next instanceof Array. var Next = [1,2,3]; Next.foo = ''bar; for (var p in Next) { // will find four elements: // 1, 2, 3, ''bar'' }

< function> for(J = 0; J< Next.length; ++ J){ <function> for (J=0;J<Next.length;++J) {

枚举数组元素给定Next instanceof Array var Next = [1,2,3]; Next.foo =''bar; for(var p in Next){ //将找到三个元素: // 1,2,3 //''bar''不是数组元素 //所以没有枚举 }

enumerates array elements given that Next instanceof Array var Next = [1,2,3]; Next.foo = ''bar; for (var p in Next) { // will find three elements: // 1, 2, 3 // ''bar'' is not an array element // so not enumerated }

我想更改第二个版本所以它给出与第一个相同的结果。 I would like to change the second version so that it gives the same results as the first one.

这是不可能的,我只是解释了原因。

It is not possible and I just explained why.

更多推荐

2次迭代

本文发布于:2023-11-29 16:30:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646950.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:迭代

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!