-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object.assign #221
Comments
hehe @nelsonic. Yes will have to look into asap |
Without mutatation (dont do this) const pair2Str = ([k, v]) => "\"" + k + "\":" + JSON.stringify(v);
const entrySeq = o => Object.keys(o).map(k => ([k, o[k]]));
const entrySeq2JSON = entrySeq => '{' + entrySeq.map(pair2Str).join(',') + '}'
const merge = objArr => JSON.parse(entrySeq2JSON(objArr
.reduce((wholeEntrySeq, obj) => wholeEntrySeq.concat(entrySeq(obj)), [])))
console.log(merge([{a: 1}, {b: 2}])) |
I can't imagine not transpiling at this point, the ES6 features are such a big quality of life improvement. I fell in love so fast with Object.assign, then dumped it for the spread operator (using Babel, I'm not sure if Closure Compiler supports that). |
@jackmoore yeah, agree
Also, forcing people to download 70MB of Babel ( 200MB on disk ) in each project (because there's no way I'm installing such a moving target of a dependency globally) and making our build/test process much slower thus eliminating the "productivity gains" achieved from typing fewer characters is not really an option ... |
Object.assign
is an _ES6_ feature I really like because it is elegant.This feels like the "right" way of combining Objects ... (why wasn't it always this way!?!?)
Object.assign
works in Node.js (V8/Chrome), but sadly, is _not available_ (and will never be available) in _Internet Explorer_:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Browser_compatibility
The ES5 version takes approx 20 seconds more to type and requires an extra line of code:
In order to write code that _Works Everywhere All-the-TimeTM_ is it time to investigate using Closure Compiler dwyl/learn-closure-compiler#1 so we can use ES6? or can people live with writing a few extra lines so we don't have to "transpile"...?
The text was updated successfully, but these errors were encountered: