<!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>

 

相关文章:

  • 2021-09-16
  • 2021-05-27
  • 2021-05-10
  • 2021-07-09
  • 2021-09-19
  • 2021-06-17
  • 2021-11-18
  • 2021-12-31
猜你喜欢
  • 2021-10-25
  • 2021-10-16
  • 2021-12-08
  • 2021-11-24
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案