JavaScript之原型链

    技术2022-07-12  86

    原型链 任何对象都有原型对象,原型对象也有原型对象,对象的原型对象一直往上找,直至找到null为止 在这个过程中,有一个Object类型的,有很多方法的对象,它就是Object.prototype,位于顶层

    <script> var nums = new Array(12, 4, 23, 5); //nums对象的原型链结构 //nums --> Array.prototype --> Object.prototype --> null var obj = new Object(); //obj --> Object.prototype --> null function Student() {} var stu = new Student(); //stu --> Student.prototype --> Object.prototype --> null </script>
    Processed: 0.010, SQL: 9