这应该很简单-在ECMA中创建一个简单的类
class Sandwich
{
constructor(filling)
{
this.sandwichname = filling;
}
}
mysandwich = new Sandwich("Peanut Butter");
Photoshop说错误9:非法使用保留字'class'第1行。
[我只能确定有一种创建类的方法-如果您原谅这个双关语,就是没有这种类型的构造。
您不能使用此版本的javascript。但是,可以像这样模拟功能:
function Sandwich(filling) {
this.filling = filling;
}
Sandwich.prototype.someMethod = function() {
console.log(this.filling);
};
var jelly = new Sandwich("jelly");
jelly.someMethod();