pan {} 允许 对象 div col 等于 es6
1. 属性和方法的简写:
- var foo = 'bar';
- var baz = {
- foo
- };
- console.log(baz); //{foo:'bar'}
ES6 允许对象中只写属性名、不写属性值,属性值等于属性名表示的变量。
- function f(x, y) {
- return {
- x,
- y
- };
- }
- console.log(f(1, 2)); //{ x: 1, y: 2 }
方法的简写:
- var ms = {};
- function getItem() {}
- function setItem() {}
- function clear() {
- ms = {};
- }
- module.exports = {
- getItem,
- setItem,
- clear
- }; //主要ES5中的getter和setter函数的写法。
ES6 对象扩展
来源: http://www.bubuko.com/infodetail-2229131.html