美文网首页
Object.assign()

Object.assign()

作者: 神刀 | 来源:发表于2017-12-31 16:08 被阅读12次

    Object.assign()
    复制一个访问器属性最终会转换为一个数据属性

    var receiver = {}

    var supplier= {
    get name(){
    return "holle world"
    }
    }

    Object.assign(receiver,supplier)

    receiver
    {name: "holle world"}

    receiver.name
    "holle world"

    supplier.name
    "holle world"

    var descriptor = Object.getOwnPropertyDescriptor(receiver,"name")
    descriptor
    {value: "holle world", writable: true, enumerable: true, configurable: true}configurable: trueenumerable: truevalue: "holle world"writable: true__proto__: Object

    var descriptor1 = Object.getOwnPropertyDescriptor(supplier,"name")
    descriptor1
    {set: undefined, enumerable: true, configurable: true, get: ƒ}configurable: trueenumerable: trueget: ƒ name()set: undefined__proto__: Object

    相关文章

      网友评论

          本文标题:Object.assign()

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