Expected method shorthand
65 spec: this.computedSpecForMINT(mint)
66 };
67 },
68 computedSpec: function(threeduftype) {69 // Get the corresponding the definitions object from the componentAPI, convert to a spec object and return70 let definition = ComponentAPI.getDefinition(threeduftype);71 let spec = [];72 for (let key in definition.heritable) {73 // const unittext = definition.units[key] !== "" ? he.htmlDecode(definition.units[key]) : "";74 let item = {75 mint: key,76 min: definition.minimum[key],77 max: definition.maximum[key],78 value: definition.defaults[key],79 units: definition.units[key],80 steps: (definition.maximum[key] - definition.minimum[key]) / 10,81 name: key82 };83 spec.push(item);84 }85 return spec;86 }87 }
88};
89</script>
Expected property shorthand
61 },
62 getEntry: function(mint) {
63 return {
64 mint: mint,65 spec: this.computedSpecForMINT(mint)
66 };
67 },
Expected method shorthand
59 console.log(tool);
60 Registry.viewManager.activateTool(tool);
61 },
62 getEntry: function(mint) {63 return {64 mint: mint,65 spec: this.computedSpecForMINT(mint)66 };67 },68 computedSpec: function(threeduftype) {
69 // Get the corresponding the definitions object from the componentAPI, convert to a spec object and return
70 let definition = ComponentAPI.getDefinition(threeduftype);
Expected method shorthand
55 };
56 },
57 methods: {
58 activateTool: function(tool) {59 console.log(tool);60 Registry.viewManager.activateTool(tool);61 },62 getEntry: function(mint) {
63 return {
64 mint: mint,
Description
ECMAScript 6 provides a concise form for defining object literal methods and properties. This syntax can make defining complex object literals much cleaner.
Here are a few common examples using the ES5 syntax:
const x = 1, y = 2, z = 3;
// properties
const foo = {
x: x,
y: y,
z: z,
};
// methods
const foo = {
a: function() {},
b: function() {}
};
The ES6 equivalent syntax is::
// properties
const foo = {x, y, z};
// methods
const bar = {
a() { return 1 },
b() { return 2 }
};
NOTE: The shorthand properties are equivalent to function expressions.
Meaning that they do not bind their own this
inside their bodies.
It is still possible to access properties from the object inside a shorthand member function:
const object = {
x: 1,
getX() {
return this.x // valid
}
}
Bad Practice
const foo = {
bar: function () { return 1 }
};
Recommended
const foo = {
bar() { return 1 }
}