代码1:
<script>
var a = ['hello' , 'javas
cript' , 'world'];
for (str in a)
document.writeln('索引' + str + '的值是:' + a[str] + "<br>" );
</script>
结果1:
索引0的值是:hello
索引1的值是:javas cript
索引2的值是:world
索引1的值是:javas
索引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)
属性on
属性cookieEnabled的值是:true
属性mimeTypes的值是: