1   for in 循环如果遍历的是数组 那么  i  就是数组的索引值

var x;
var person=[456,"qwe",890];
for (x in person)
{
alert(x); //依次显示 0 1 2
}

2   for in循环如果遍历的是对象 那么 i 就是对象的属性名

var x;
var person={fname:"Bill",lname:"Gates",age:56};
for (x in person)
{
alert(x); //依次显示 fname lname age
alert(person[x]); // 得到对象的属性值 不能写person.x 这是undefined
}

随机推荐

  1. Delphi Interfaces

    http://www.delphibasics.co.uk/Article.asp?Name=Interface The reason for interfaces   Classes that ex ...

  2. MySQL 127.0.0.1和localhost本质区别

    登录方式: [root@10-4-14-168 ~]# mysql -uroot -p Enter password: 查看权限表 mysql> SELECT user,host,passwor ...

  3. [Angular2 Router] CanActivate Route Guard - An Example of An Asynchronous Route Guard

    In this tutorial we are going to learn how we can to configure an can activate route guard in the An ...

  4. jquery validate 小demo

    方便学习: 直接上代码: ceshi.html: <!DOCTYPE html> <html> <head> <meta http-equiv="C ...

  5. 提高HTML5 canvas性能的几种方法

    简介 HTML5 canvas 最初起源于苹果(Apple)的一项实验,现在已经成为了web中受到广泛支持的2D快速模式绘图(2Dimmediate mode graphic)的标准.许多开发者现在利 ...

  6. 线性表 及Java实现 顺序表、链表、栈、队列

    数据结构与算法是程序设计的两大基础,大型的IT企业面试时也会出数据结构和算法的题目, 它可以说明你是否有良好的逻辑思维,如果你具备良好的逻辑思维,即使技术存在某些缺陷,面试公司也会认为你很有培养价值, ...

  7. WSS3.0 SDK中的不同列表类型的对应值

    Value Description 100 Generic list 101 Document library 102 Survey 103 Links list 104 Announcements ...

  8. Tomcat中部署WEB项目的四种方法

    对Tomcat部署web应用的方式总结,常见的有以下四种: 1.[使用控制台部署] 访问Http://localhost:8080,并通过Tomcat Manager登录,进入部署界面即可. 2.[利 ...

  9. Ubuntu下VSFTPD(五)(匿名FTP设置方法)

    匿名FTP设置方法: 通常在登录FTP服务器的用户不确定的情况下,应将FTP服务器设置为允许匿名账号登录的FTP服务器 1.启用匿名帐号   anonymous_enable=YES   local_ ...

  10. Linux 命令 alternatives和update-alternatives

    参考: http://lionbule.iteye.com/blog/717722 http://manpages.ubuntu.com/manpages/oneiric/man8/update-al ...