zoukankan      html  css  js  c++  java
  • get/set

    const obj = {
      get foo() {},
      set foo(x) {}
    };
    
    obj.foo.name
    // TypeError: Cannot read property 'name' of undefined
    
    const descriptor = Object.getOwnPropertyDescriptor(obj, 'foo');
    
    descriptor.get.name // "get foo"
    descriptor.set.name // "set foo"


    有两种特殊情况:bind方法创造的函数,name属性返回bound加上原函数的名字;Function构造函数创造的函数,name属性返回anonymous

    (new Function()).name // "anonymous"
    
    var doSomething = function() {
      // ...
    };
    doSomething.bind().name // "bound doSomething"
    
     
  • 相关阅读:
    SonarQube
    Gerrit
    Jenkins
    Jenkins
    GitLab
    GitLab
    GitLab
    centos7配置国内yum源
    CentOS7 ping: unknown host www.baidu.com
    VirtualBox下安装CentOS7系统
  • 原文地址:https://www.cnblogs.com/justart/p/8166091.html
Copyright © 2011-2022 走看看