您的位置:首页 > Web前端 > JavaScript

js中 for - in 循环

2016-11-07 16:12 225 查看


关于JS的for in循环  

2009-09-10 17:49:03|  分类: JavaScript|举报|字号 订阅

    





  下载LOFTER我的照片书  |

代码1:
<script>
var a = ['hello' , 'javascript' , 'world'];
for (str in a)
document.writeln('索引' + str + '的值是:' + a[str] + "<br>" );
</script>
结果1:
索引0的值是:hello

索引1的值是:javascript

索引2的值是:world

代码2:

<script>
document.write("<h1>Navigator对象的全部属性如下:</h1>");
for (propName in navigator)
{
//输出navigator对象的所有属性名以及对应的属性值
document.write('属性' + propName + '的值是:' + navigator[propName]);
document.write("<br />");
}
</script>
结果2:

Navigator对象的全部属性如下:

属性appCodeName的值是:Mozilla

属性appName的值是:Microsoft Internet Explorer

属性appMinorVersion的值是:;SP3;

属性cpuClass的值是:x86

属性platform的值是:Win32

属性plugins的值是:

属性opsProfile的值是:

属性userProfile的值是:

属性systemLanguage的值是:zh-cn

属性userLanguage的值是:zh-cn

属性appVersion的值是:4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; CIBA)

属性userAgent的值是:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; CIBA)

属性onLine的值是:true

属性cookieEnabled的值是:true

属性mimeTypes的值是:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: