DEV Community

Discussion on: PHP 8 features I wish also existed in JavaScript

Collapse
 
tomaszs2 profile image
Tom Smykowski • Edited

3 - it means for 15% of internet users app or website using optional chaining will break because older browsers does not support it.

Collapse
 
peerreynders profile image
peerreynders

Given that you are supposed to be practicing Differential Serving anyway it's a non-issue.

ESNext is transpiled down to ES2017 to yield smaller bundles for modern browsers while larger bundles transpiled all the way down to ES5 are available for legacy browsers.

A Universal Bundle Loader
Bringing Modern JavaScript to Libraries
Publish, ship, and install modern JavaScript for faster applications

Thread Thread
 
tomaszs2 profile image
Tom Smykowski

Still, the post is a comparison between JavaScript and PHP, and you write about EcmaScript:

  • 15% of users have browsers with JavaScript that does not support optional chaining
  • I have to use transpiler from EcmaScript to JavaScript to be able to use it

= JavaScript does not support optional chaining

Thread Thread
 
peerreynders profile image
peerreynders

JavaScript is nothing more than a trademark of ORACLE America, Inc. which they obtained through their acquisition of Sun Microsystem, Inc.. The trademark was licensed by Sun to Netscape and later to the Mozilla Foundation.

Other than that JavaScript is just a colloquialism to refer to the scripting language features that are used for browser automation. ECMAScript is an effort to standardize that scripting language. As it is, no browser claims to implement any ECMAScript spec in full - they only aspire to do so (and often they implement features beyond the spec).

Back in the day we used jQuery to bridge gap between the variations between different browser vendor implementations. Today we use Babel to bridge the gaps that have emerged over time. The more things change, the more they stay the same - so while the tools have changed, we still have to bridge gaps.

You are free to use whatever dialect you prefer - though I don't envy anyone who may have to help support your work.

But ES2020 includes the Optional chaining (?.) operator so it is now part of what people colloquially refer to as "JavaScript" - MDN lists it under the JavaScript Reference - and it is available to everyone to use via Babel.