ES6: add object literal enhancements

This commit is contained in:
Rico Sta. Cruz 2015-02-25 15:55:54 +08:00
parent bb2bf8f0a0
commit 91738c082d
1 changed files with 30 additions and 5 deletions

35
es6.md
View File

@ -48,13 +48,9 @@ world
`;
```
### Syntax improvements
### Other improvements
```js
// Short object syntax
// aka: `exports = { hello:hello, bye:bye }`
module.exports = { hello, bye };
// New string methods
"hello".repeat(3)
"hello".contains("ll")
@ -65,6 +61,35 @@ var bin = 0b1010010;
var oct = 0755;
```
### Object literal enhancements
```js
// Short object syntax
// aka: `exports = { hello:hello, bye:bye }`
module.exports = { hello, bye };
App = {
// shorthand for `handler: handler`
handler,
// methods
start() {
this.go();
},
// getter/setter
get closed() {
return this.status === 'closed';
},
// custom prototypes
__proto__: protoObj,
// computed property names
[ "prop_"+n ]: 42
};
```
## Stable ([Babel])
Available via [Babel]