美文网首页
Object.create()

Object.create()

作者: 小李不小 | 来源:发表于2021-07-28 15:19 被阅读0次

Object.create()方法创建一个新对象,使用现有的对象来提供新创建的对象的proto

var a = {
                show(){
                    console.log(12)
                }
            }
            var c = Object.create(a)
            console.log(Object.getPrototypeOf(c))
            console.log(Object.create(a).__proto__)
            var b = {}
            // b.__proto__=a
            Object.setPrototypeOf(b,a)
            console.log(b.__proto__)

相关文章

网友评论

      本文标题:Object.create()

      本文链接:https://www.haomeiwen.com/subject/gnvuektx.html