How To Know Javascript Version

JavaScript is one of the core technologies that powers the modern web. It is frequently updated, and new features are constantly being added. In this blog post, we’ll discuss how you can find out which version of JavaScript is running on your browser.

ECMAScript and JavaScript Versions

Before we dive into the details, it’s essential to understand the difference between ECMAScript and JavaScript. ECMAScript is a standard for scripting languages, and JavaScript is an implementation of that standard. When people talk about JavaScript versions, they’re often referring to the ECMAScript version that the JavaScript engine in their browser supports.

The ECMAScript version essentially dictates which JavaScript features are available in that version. ECMAScript versions are identified by their release year, such as ES2015, ES2016, and so on. With this in mind, let’s figure out how to find out which ECMAScript version your browser supports.

Checking JavaScript Version in Your Browser

Unfortunately, there’s no built-in function that returns the JavaScript version in your browser. However, you can determine whether your browser supports specific ECMAScript features by executing some code snippets.

Arrow Functions (ES2015)

To check if your browser supports arrow functions, which were introduced in ES2015, you can try executing the following code snippet in your browser’s JavaScript console:

// ES2015 Arrow Functions
try {
  eval("() => {}");
  console.log("Arrow functions are supported");
} catch (error) {
  console.log("Arrow functions are not supported");
}

If your browser supports arrow functions, you’ll see the message “Arrow functions are supported” in the console.

Async/Await (ES2017)

Similarly, you can check for support of async/await, which was introduced in ES2017, using the following code snippet:

// ES2017 Async/Await
try {
  eval("async () => {}");
  console.log("Async/await is supported");
} catch (error) {
  console.log("Async/await is not supported");
}

If your browser supports async/await, you’ll see the message “Async/await is supported” in the console.

Conclusion

While there’s no direct way to find out the JavaScript version in your browser, you can determine if specific ECMAScript features are supported by running code snippets that utilize these features. By doing this, you can get an idea of which ECMAScript version your browser supports, which in turn gives you an idea of the functionality available to you in JavaScript.