Professional JS: Features You Need to Know

JavaScript Features Q&A

Maximiliano Firtman

Maximiliano Firtman

Independent Consultant
Professional JS: Features You Need to Know

Check out a free preview of the full Professional JS: Features You Need to Know course

The "JavaScript Features Q&A" Lesson is part of the full, Professional JS: Features You Need to Know course featured in this preview video. Here's what you'd learn in this lesson:

Maximiliano answers student questions regarding the relationship between ECMAScript and TypeScript and how quickly TypeScript implements new features introduced by ECMAScript. He also addresses questions of whether TypeScript will become the standard for web development and the decision-making process for choosing the target version of ECMAScript when transpiling code.

Preview
Close

Transcript from the "JavaScript Features Q&A" Lesson

[00:00:00]
>> Audience: How long after ECMA introduces a new feature does it take for TypeScript to also implement it?
>> Maximiliano Firtman: So, typically they are fast enough, and to be honest, there are some features, at least today. Some ECMAScript new features that are actually sometimes coming from TypeScript, or they are very similar in TypeScript.

[00:00:25]
That also adds sometimes a challenge on the TypeScript team, because sometimes the ECMA, the technical committee, they make a different decision on how to implement the feature. So then TypeScript has a challenge of how to support both, now the ECMAScript and their own version of that. But typically, they are fast enough, I don't have the explicit answer to say it's always like six months, or things like that.

[00:00:56]
But they are keeping up to date to ECMAScript, most of the time, because they tend to be a superset. And when you are a superset, it's not that different language, it's something on top of, so it's like a plugin on top of. So that's why they're typically fast to apply these new changes.

[00:01:17]
Also remember that when you transpile TypeScript, you transpile into ECMAScript. We don't have TypeScript runtimes. So at the end, the browser will be ECMAScript, will run ECMAScript, or Node.js will run ECMAScript. Another question, yeah.
>> Audience: Do you think TypeScript or something like it will become standard?
>> Maximiliano Firtman: That's an interesting question.

[00:01:46]
>> Maximiliano Firtman: So, TypeScript becoming the standard for the web, I don't think it's going to happen, I think there are a lot of people pushing that. I don't think it's going to happen because we have a lot of people that thinks that adding types to JavaScript is a good idea, but also there are a lot of people saying that it's not a good idea.

[00:02:06]
So it's not that 100% of the communities is with, let's add types to JavaScript. So, actually Google tried to push a new language, also typed language, strict typed language for the web. Once, and it didn't work. Microsoft did that with VBScript, it didn't work, in the 90s. In 2008, something around that, Google tried to push Dart to replace JavaScript, it didn't work.

[00:02:41]
So, I don't think TypeScript will win that fight anyway. So I don't think it's going to happen, I think we will still work with this transpiling thing for a while. Maybe in the future, because now with WebAssembly, the web and ECMAScript or JavaScript in general, it's more flexible now.

[00:03:06]
So you can run Python client-side these days, I'm not sure if you know that. Because you can ship your own Python interpreter in WebAssembly. So then you can run, it's kind of native Python client-side. And with that in mind, you can run anything client-side, including TypeScript. So I think that maybe in the future, that's one future, a way to use the language you want, and then you just ship WebAssembly, or a WebAssembly interpreter, for your code.

[00:03:44]
Now, for example, Dart, that's with Flutter as well, when you're doing Flutter apps, and you compile to a progressive web app, so a web app, that web app is using WebAssembly by default. So, it's not even shipping JavaScript anymore, it's shipping WebAssembly, and so I think that for the future, I think that might answer the question.

[00:04:04]
Maybe you will be able to natively run TypeScript by shipping a TypeScript engine. I'm not sure if that's gonna happen, but that's a possible future. I don't think it's going to become a standard, we'll see.
>> Audience: I always have trouble picking which version to transpile down to. How do you make that decision?

[00:04:28]
>> Maximiliano Firtman: That's a good question. So, which version of ECMAScript we should be using as a target for shipping our code? I think I do have a slide for that later, but let's say, five years ago, the normal, the standard was actually to ship to ES5, okay? ES5, it's 2009, okay, we're talking about 15 years ago.

[00:04:57]
I think that's going too much to be honest, the only browser that has 0.8% still there, it's IE11. Old corporate users maybe working on some old banks somewhere, they're still in Windows XP with IE11. If you need to target those, you will serve, unfortunately, ES5 is still the answer.

[00:05:26]
For the rest, ES6 is safe. And I could argue that, and we will see that later that these days if you target 2020, for example, you're probably a 97% of the population. So, yeah, the problem is what happened with the 3%, okay? Well, first, maybe you have to check in your analytics, and checking your website, based on your audience, which browsers they're using to see.

[00:05:57]
Because maybe you can start working with modern ECMAScript without transpilation and that's not a problem. Maybe, it depends on the audience that you have, okay? So these days, I will say that the three answers are, ES5 in the rare case that you still need to cover all those enterprise users using still CD based browsers.

[00:06:25]
And we have ES6 if you wanna be safe, 100% of users, normal users, or ES2020 for the rest if you wanna be more on the edge, okay? That's if you are going to use a transpiler, those are the three possibilities that works these days.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now