getMousePosition
是一个返回了拥有2个属性的对象的简单函数。
ES6 提供了一个语法糖,消除了类似x: x
这种冗余的写法.你可以仅仅只写一次x
,解释器会自动将其转换成x: x
。
下面是使用这种语法重写的同样的函数:
```js
const getMousePosition = (x, y) => ({ x, y });
```
Person
对象。
{name: "Zodiac Hasbro", age: 56, gender: "male"}
。'
testString: assert.deepEqual({name:"Zodiac Hasbro",age:56,gender:"male"}, createPerson("Zodiac Hasbro", 56, "male"));
- text: '不要使用key:value
。'
testString: getUserInput => assert(!getUserInput('index').match(/:/g));
```