0

web_dev_style: add "Object literal extensions" to allowed ES

Discussion: https://groups.google.com/a/chromium.org/d/msg/chromium-dev/RqOdTlxuGVg/M7I0CTryDQAJ

Bug: None
Change-Id: I43cb19e50bf9addc530d728f4f002afa16bd6f5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1993388
Commit-Queue: Dan Beam <dbeam@chromium.org>
Auto-Submit: Dan Beam <dbeam@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729898}
This commit is contained in:
Dan Beam
2020-01-09 21:18:52 +00:00
committed by Commit Bot
parent 8026ec61cc
commit 7903a936dc

@ -588,6 +588,47 @@ section.
---
### Object Literal Extensions
Convenient new ways for object property definition.
**Usage Example:**
```js
// Computed property name
const prop = 'foo';
const o = {
[prop]: 'hey',
['b' + 'ar']: 'there',
};
console.log(o); // {foo: 'hey', bar: 'there'}
// Shorthand property
const foo = 1;
const bar = 2;
const o = {foo, bar};
console.log(o); // {foo: 1, bar: 2}
// Method property
const clearSky = {
// Basically the same as clouds: function() { return 0; }.
clouds() { return 0; },
color() { return 'blue'; },
};
console.log(clearSky.color()); // 'blue'
console.log(clearSky.clouds()); // 0
```
**Documentation:** [link](https://tc39.github.io/ecma262/#sec-object-initialiser)
[link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer)
**Discussion Notes / Link to Thread:**
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/RqOdTlxuGVg/M7I0CTryDQAJ
Note: clang-format has some issues formatting complex computed property names.
---
## Banned Features
The following features are banned for Chromium development.
@ -655,44 +696,6 @@ hide(document.body, false); // Not animated.
---
### Object Literal Extensions
Convenient new ways for object property definition.
**Usage Example:**
```js
// Computed property name
const prop = 'foo';
const o = {
[prop]: 'hey',
['b' + 'ar']: 'there',
};
console.log(o); // {foo: 'hey', bar: 'there'}
// Shorthand property
const foo = 1;
const bar = 2;
const o = {foo, bar};
console.log(o); // {foo: 1, bar: 2}
// Method property
const clearSky = {
// Basically the same as clouds: function() { return 0; }.
clouds() { return 0; },
color() { return 'blue'; },
};
console.log(clearSky.color()); // 'blue'
console.log(clearSky.clouds()); // 0
```
**Documentation:** [link](https://tc39.github.io/ecma262/#sec-object-initialiser)
[link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer)
**Discussion Notes / Link to Thread:**
---
### Binary & Octal Literals
**Usage Example:**