r/programming • • Apr 29 '21

Modern JavaScript Explained For Dinosaurs

https://medium.com/the-node-js-collection/modern-javascript-explained-for-dinosaurs-f695e9747b70
287 Upvotes

172 comments sorted by

View all comments

62

u/sylvanelite Apr 30 '21

It's worth noting that since this was written, javascript modules now exist in the browser, so you can write models kinda like in the article, without using the command line tools.

But annoyingly, there's some quirks. They syntax isn't the same as in the article. For example:

var moment = require('moment');

can be replaced with something like:

import moment from 'moment';

And if doing it the "dinosaur" way, instead of having javascript files like:

<script type="text/javascript" src="file.js" ></script>

you can do something like:

<script type="module" src="module.mjs"></script>

13

u/jtinz Apr 30 '21

The problem is that when you're developing for "the real world", you usually have to support IE11, which doesn't seem to support anything specced in the last decade.

5

u/ShaelThulLem Apr 30 '21

That's just poor decision making to support that dinosaur.

7

u/jtinz Apr 30 '21

I didn't write the spec. It looks like IE11 still has 5% market share.

6

u/haykam821 Apr 30 '21

Our assassins are working diligently.

3

u/earthboundkid Apr 30 '21

I see less than 1% in my Google Analytics.