Use object.assign instead of extend
🤔Type of Request
- [ ] Bug fix
- [ ] New feature
- [x] Improvement
- [ ] Documentation
- [ ] Other
🔗Resolves an issue?
- part of #4796 #5526 (got to start out small)
📝Changelog
- [ ] Core
- [x] Extensions
💡Example(s)?
☑️Self Check before Merge
⚠️ Please check all items below before review. ⚠️
- [ ] Doc is updated/provided or not needed
- [ ] Demo is updated/provided or not needed
- [ ] Changelog is provided or not needed
I'm not sure if i'm a fan to use only assign instead of Object.assign.
Does this have any advantages, because it's not that readable (especially for new devs in the project).
Also i'm not sure if we should replace $.extend with Object.assign or if we should write our own method for that (i think we need a custom function for deep copy either way).
The extend function from jquery is faster then Object.assign if this benchmark is correct.
Executed the test myself... it showed that spread was a clear winner in both safari and in chrome and that jQuery.extend was the slowest. chrome 104: https://www.measurethat.net/Benchmarks/ShowResult/326203 safari 15.6: https://www.measurethat.net/Benchmarks/ShowResult/326205
using const { assign } = Object instead of Object.assign makes it a tiny bit more friendlier for the other stuff to be GC, helps with code minification and also has a faster path lookup to increase perf b/c it's cached to a more closer local scope
anyhow this stuff didn't extend anything deeply so nothing like extend deep functionallity had to be written
the nice thing about using built in solution also is that stack traces gets shorter and easier to debug
Firefox: https://www.measurethat.net/Benchmarks/ShowResult/326214
using const { assign } = Object instead of Object.assign makes it a tiny bit more friendlier for the other stuff to be GC, helps with code minification and also has a faster path lookup to increase perf b/c it's cached to a more closer local scope
I think our build script automatically optimize that, or not @wenzhixin ?
I think our build script automatically optimize that.
Yes
@wenzhixin @djhvscf your opinions about this ?
I think we can modify the code in all src, not just this extension.
@wenzhixin and what do you think about the benchmarks ?
Updated in #6560