Today I Learned - Rocky Kev

TIL that JS is backwards compatible

POSTED ON:

TAGS:

tl;dr: TC39 often proclaim, "We don't break the web!" with new advancements in JS.

Note: TC39 is the ECMA Technical Committee overseeing the standardization of ECMAScript.

Backwards Compatibility: (Thanks to transcompilers like Babel)

Backwards compatibility means that once something is accepted as valid JS, there will not be a future change to the language that causes that code to become invalid JS. Code written in 1995—however primitive or limited it may have been!—should still work today. As TC39 members often proclaim, “we don't break the web!”

The idea is that JS developers can write code with confidence that their code won't stop working unpredictably because a browser update is released. This makes the decision to choose JS for a program a more wise and safe investment, for years into the future.

Not Forward Compatability:

It doesn't skip over future additions, and insteads break. Preferrably, you're running that code through Babel to ensure that it works with old versions in JS.

JS is not forwards-compatible, despite many wishing such, and even incorrectly believing the myth that it is.

HTML and CSS, by contrast, are forwards-compatible but not backwards-compatible. If you dug up some HTML or CSS written back in 1995, it's entirely possible it would not work (or work the same) today. But, if you use a new feature from 2019 in a browser from 2010, the page isn't “broken” – the unrecognized CSS/HTML is skipped over, while the rest of the CSS/HTML would be processed accordingly.

Via You Don't Know JS (2nd edition)


Related TILs

Tagged:

TIL what is npm Script

Despite their high usage they are not particularly well optimized and add about 400ms of overhead. In this article we were able to bring that down to ~22ms.

TIL fancy methods to transform Javascript Objects

You can use Object.entries(), Object.keys(), Object.fromEntries()...

TIL how to hide your JS code

ONE THING TO NOTE: Encrypting a script is stronger than obfuscation, both methods are still not adequate to protect secret content. Honestly, I don't think it's worth it on a production site, and instead just go with pure server-side if you want security. But it's fascinating.