class Person{
constuctor(name){
this.name = name;
}
speak(){
alert('My name is ' + this.name);
}
}
var james = new Person('james');
james.speak();
我想了解一些节点的ES6类的东西。 我发现每个例子都说这应该
对于es6我很新。以下是我的简单Student类与接受2个参数的构造函数。我通过在构造函数签名本身中调用函数来分配默认值,当参数未被传递时。 index.js:9Uncaught TypeError: this.defaultRno is not a function
at new Student (index.js:9)
at Object.<anonymous> (inde
我想弄清楚这里发生了什么,因为父类/超类在初始构建后没有数据。 //进口/服务器/一 - 和 - b.js class A {
constructor(id) {
// make MongoDB call and store inside this variable
// ...
this._LocalVariable = FieldFromMongo;
我想使用ES6解构一个类的构造函数,但得到一个未知的令牌错误。这里有一个例子: //进口/服务器/ A-和b.js class A {
constructor(id) {
// make MongoDB call and store inside this variable
let {
firstName: this._FirstName // => Th