Is property value shorthand in objects compatible with all browsers?

Question

Is property value shorthand in objects compatible with all browsers?

Answer

Not quite, most are, but Internet Explorer 11 is not compatible, although there are libraries called transpilers, like babel, that can be used to change our code from ES6+ to ES5 once we are done writing and we are ready to test everywhere.

18 Likes

thanks for the heads up

1 Like

Thank you for your insight! Is there any way of finding out the compatibility for each browser?

yep, caniuse is often very helpful. Couldn’t find it on there, with some googling i got to MDN:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer

at the bottom is browser compatibility table, including Shorthand property names, only Internet Explorer has no support at all.

8 Likes

Perfect! Thank you - I’ve got this bookmarked. It wouldn’t surprise me that IE wouldn’t have any support :rofl:

1 Like

That is very correct

Who uses Internet Explorer in 2020 anyways? Microsoft even dropped it in favor of their new Microsoft edge browser which uses the same engine as google chrome

2 Likes

Some companies like banks. We all hate Microsoft (Internet Explorer), but some people have to work with it.

2 Likes

HaHaHaHaHaHa…

Thanks for the good laugh. I needed a good laugh while reading through this lesson :wink:

Even though ‘no one’ uses it, clients often want their website to be compatible with IE probably because they think people actually use IE - of course, some companies use IE as it can be hard to switch a whole company’s browser

So in the end, try to always make your website compatible with as many browsers as you can