Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What browsers currently support JavaScript's 'let' keyword?

I'm developing an app and don't have to ever worry about Internet Explorer and was looking into some of the features present in A+ grade browsers that aren't in Internet Explorer1.

One of these features I wanted to play around with is JavaScript's let keyword

I can't seem to get any of their 'let' examples to work in Firefox 3.6 (User-Agent string: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)). I get SyntaxError: missing ; before statement when executing let foo = "bar".

So, what browsers support the let keyword? (Or am I doing something wrong?)

like image 656
David Murdoch Avatar asked Mar 01 '10 15:03

David Murdoch


People also ask

Does Internet Explorer support let?

Browser SupportThe let keyword is not fully supported in Internet Explorer 11 or earlier.

Can I use let in JavaScript?

The let keyword in Javascript was introduced in 2015 with ES6. Just like var in Javascript, let keyword is also used for variable declaration. But the only difference is the variable declared with the “let” keyword is block-scoped and local variable.

Do all browsers support ES2020?

Browser vendors don't implement specific versions, but specific features. Almost every modern browser is still missing features from ES2017-ES2020. Hence there is not and won't be a table where you can see an ES version to browser version mapping.

Do any browsers still support JavaScript?

All the modern browsers come with built-in support for JavaScript. Frequently, you may need to enable or disable this support manually. This chapter explains the procedure of enabling and disabling JavaScript support in your browsers: Internet Explorer, Firefox, chrome, and Opera.

What browsers support the ES6 let keyword?

On browser environments you should include the JavaScript version number in your script tag to use it: Show activity on this post. All up-to-date major browsers such as Chrome, Firefox, and Edge support the ES2015 (aka "ES6") let keyword. iOS Safari did not support let until OS 10 (e.g, OS 9 did not).

Does Internet Explorer 10 support'let'keywords?

Apparently Internet Explorer 10 in Edge mode supports let, per JavaScript Version Information. Show activity on this post. A great deal of time has passed since this question was first asked: the 'let' and 'const' keywords have been introduced in ECMAScript 2015 (ES6).

What are the new keywords in ECMAScript 2015?

ECMAScript 2015. ES2015 introduced two important new JavaScript keywords: let and const. These two keywords provide Block Scope variables (and constants) in JavaScript. Before ES2015, JavaScript had only two types of scope: Global Scope and Function Scope .

What version of JavaScript does Internet Explorer support?

Internet Explorer and Opera don't support let on any browser version, Firefox since version 2.0 and Safari since 3.2. See this JavaScript version table on Wikipedia. I just found out that you need to define whether you use JavaScript 1.7 or not.


1 Answers

EDIT: let and const are supported by all modern browsers and are part of the ECMAScript 2015 (ES6) specification.

Basically if you don't need to support anything below IE11, let and const are safe to use nowadays.

On IE11 there's a small quirk with let when used with for loops, the variable is not bound to the for block as you would expect, it behaves as var did...

See also: let and const support.


Old and outdated answer from 2010: Those extensions are not ECMA-Standard, they are supported only by the Mozilla implementation.

On browser environments you should include the JavaScript version number in your script tag to use it:

<script type="application/javascript;version=1.7">     var x = 5;   var y = 0;    let (x = x+10, y = 12) {     alert(x+y + "\n");   }    alert((x + y) + "\n"); </script> 
like image 151
Christian C. Salvadó Avatar answered Sep 17 '22 18:09

Christian C. Salvadó