The back-tick character is not recognized as a Valid Character in IE11 when using the "use strict" directive while it works in other browsers, such as Chrome.
What is the interpretation of this behavior taking into consideration that IE11 is still widely used even among Windows 10 users??
"use strict"; function doIt() { let tt; tt = 50; alert(`${tt}`); alert("test"); } doIt();
Error: { "message": "Invalid character", "filename": "http://stacksnippets.net/js", "lineno": 18, "colno": 17 }
If you look at the ECMAScript 6 compatibility table, you'll see that template literals are not supported by IE11.
If you are using JavaScript's new template literal syntax in a JSP page it might not work as expected. That's because JSP and JavaScript both use the ${myVar} syntax.
Description. Template literals are enclosed by backtick (`) characters instead of double or single quotes. Along with having normal strings, template literals can also contain other parts called placeholders, which are embedded expressions delimited by a dollar sign and curly braces: ${expression} .
If you look at the ECMAScript 6 compatibility table, you'll see that template literals are not supported by IE11. The "use strict";
statement doesn't really change anything, because before it is determined whether a code is in strict mode, it has to be parsed first, but it can't be parsed, because you're using syntax that the parser doesn't recognize.
If you want your code to work in IE11, you should transpile it with Babel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With