5 ms·
el.email = { document.createElement('input'), ...{ type: 'email' }}
by ErikHuisman 10y ago
el.email = { document.createElement('input'), ...{ type: 'email' }}
- klibertp 10y agoWhat supports this feature and how is it implemented?
- yawgmoth 10y agoThe ... is the spread operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- yawgmoth 10y ago(Too long to edit my other reply) Also used was object destructuring: http://odetocode.com/blogs/scott/archive/2014/09/11/features-of-es6-part-6-destructuring.aspx http://odetocode.com/blogs/scott/archive/2014/09/11/features...
- AgentME 10y agoI know about the spread operator, but I'm pretty sure that's invalid. `var foo = { document.createElement('input') };` doesn't work, spread or no spread after it.
- ErikHuisman 10y agoOw man.. I saw the Object.assign example and thought i don't like it because it requires an extra polyfill. I can just use a spread and let babel handle it. If anything it should be `var email = {...document.createElement('input'), type: 'email'}` But that would result in `Object.assign({}, document.createElement('input'), { type: 'email' })` Got 4 up votes though..