function palabra clave de la siguiente manera: const persona = {Con ES6, puede eliminar la palabra clave de
nombre: "taylor",
sayHello: function () {
vuelve `hola! Mi nombre es $ {this.name} .`;
}
};
function y los dos puntos por completo al definir funciones en objetos. Aquí hay un ejemplo de esta sintaxis: const persona = {
nombre: "taylor",
di hola() {
vuelve `hola! Mi nombre es $ {this.name} .`;
}
};
setGear dentro de la bicycle objeto para usar la sintaxis abreviada descrita anteriormente. function expression was not used.");'
- text: setGear es una función declarativa.
testString: 'assert(typeof bicycle.setGear === "function" && getUserInput("index").match(/setGear\s*\(.+\)\s*\{/), "setGear is a declarative function.");'
- text: bicycle.setGear(48) cambia el valor del gear a 48.
testString: 'assert((new bicycle.setGear(48)).gear === 48, "bicycle.setGear(48) changes the gear value to 48.");'
```