const getMousePosition = (x, y) => ({
x: x,
y: y
});
getMousePosition
es una función simple que devuelve un objeto que contiene dos campos.
ES6 proporciona el azúcar sintáctico para eliminar la redundancia de tener que escribir x: x
. Simplemente puede escribir x
una vez, y se convertirá a x: x
(o algo equivalente) debajo del capó.
Aquí se reescribe la misma función de la anterior para usar esta nueva sintaxis:
const getMousePosition = (x, y) => ({ x, y });
Person
.
{name: "Zodiac Hasbro", age: 56, gender: "male"}
.'
testString: 'assert(() => {const res={name:"Zodiac Hasbro",age:56,gender:"male"}; const person=createPerson("Zodiac Hasbro", 56, "male"); return Object.keys(person).every(k => person[k] === res[k]);}, "the output is {name: "Zodiac Hasbro", age: 56, gender: "male"}
.");'
- text: 'No :
fueron utilizados'
testString: 'getUserInput => assert(!getUserInput("index").match(/:/g), "No :
were used.");'
```