-1

I found this plugins in .babelrc file

"plugins": [
["transform-replace-object-assign", "object.assign"] ]

and as i know Object.assign() is built-in method in all modern browsers.

So why using it as plugins inside .babelrc?

Thanks.

Jalal
  • 3,308
  • 4
  • 35
  • 43
  • 3
    It's not supported in IE – user184994 Nov 26 '17 at 20:42
  • 1
    It a polyfill for older browsers that don't support it. – ibrahim mahrir Nov 26 '17 at 20:43
  • Reductio ad absurdum: Why use babel whatsoever? – Dexygen Nov 26 '17 at 20:44
  • @GeorgeJempty what do you suggest? – Jalal Nov 26 '17 at 21:01
  • @JimmyJanson I was making a type of logical argument that could be a(n absurd) follow-up to your original question -- why use Babel whatsoever if various methods such as `Object.assign` are built-in? The answer is, because Babel is specifically meant for when these methods are *not* built-in, e.g. non-modern browsers. So keep using Babel -- but maybe look up "reductio ad absurdum": https://en.wikipedia.org/wiki/Reductio_ad_absurdum – Dexygen Nov 26 '17 at 21:21

2 Answers2

2

It depends how you define "modern browsers". Object.assign isn't present in Internet Explorer, which accounts for about one in eight users at the time of writing.

Whatever the case, depending on the purpose of your website, you may wish to support all kinds of users using all kinds of browsers. Remember, many users are unable or unwilling to upgrade their browser for various reasons.

qntm
  • 4,147
  • 4
  • 27
  • 41
1

Object.assign is not supported in IE.

It's not about supporting modern browsers - but as many browsers as possible. That said, it's always a good idea to include babel and polyfills for older browsers so you can write in modern JS but still support the less modern browsers.

itamar
  • 3,837
  • 5
  • 35
  • 60
  • it came with price i guess, more bandle size if want to install the method as dependency – Jalal Nov 26 '17 at 20:52
  • 1
    Always a trade-off. You can also just use something like lodash which takes care of polyfilling so you can use the same syntax and it'll just default back if static object methods are not supported. – itamar Nov 26 '17 at 20:53