I read the ES2015 primer on this site , and this example was given for the names of the calculated properties :
const namespace = '-webkit-';
const style = {
[namespace + 'box-sizing'] : 'border-box',
[namespace + 'box-shadow'] : '10px10px5px #888888'
};
It's pretty straightforward, but I don't understand what Babel is doing to block him. He gives the following:
var _style;
var namespace = '-webkit-';
var style = (
_style = {},
_style[namespace + 'box-sizing'] = 'border-box',
_style[namespace + 'box-shadow'] = '10px 10px 5px #888888',
_style
);
(I reformatted the indentation)
Online Babel Transpilation is here
I canโt find the documentation about what the syntax is: declaring an object _style, then listing in paranthesis the names of the properties and their values, and then just ends on , _styleuntil the end of the parthenthesis.
source
share