<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> function f(start) { this.name = "test"; this.index = 123; } var a = new f(); var b = new Object(); var c = ["aaa"]; c.testProperty = 1; /*JS中数组是可以直接给他赋一个属性值的,数组长度只有1,这样alert的时候就是数组的一个值了。 * 正则表达式里的exec函数就是返回一个长度为1的数组*/ alert(a);/*object Object*/ // alert(f); alert(b);/*object Object 自定义型对象*/ console.log(a);/*object console.log打印出的还和alert打印出来的不完全一样*/ alert(typeof(c)+" "+c); /*这里上面是那种有属性值的对象是如何打印出默认值的。如上半部分解释*/ // a.0 = "hello"; </script> </body> </html>