как свойства babel-plugin-transform-class-properties обрабатывают свойства - PullRequest
0 голосов
/ 28 июня 2018

почему babel-plugin-transform-class-properties добавляет свойства, значение которых является функцией экземпляра, а не прототипа конструктора?

class Bork {
//Property initializer syntax
instanceProperty = "bork";
boundFunction = () => {
  return this.instanceProperty;
}

//Static class properties
static staticProperty = "babelIsCool";
static staticFunction = function() {
    return Bork.staticProperty;
  }
}

let myBork = new Bork;

//Property initializers are not on the prototype.
console.log(myBork.__proto__.boundFunction); // > undefined

//Bound functions are bound to the class instance.
console.log(myBork.boundFunction.call(undefined)); // > "bork"

//Static function exists on the class.
console.log(Bork.staticFunction()); // > "babelIsCool"

почему свойство "boundFunction" отсутствует у прототипа?

...