SyntaxError : Reserved Word
Tags: tester, learning, showdev
Published: 2019-04-19 10:54:22

---
title: SyntaxError : Reserved Word
published: true
description: Strict mode has become a necessity because of its many benefits. It keeps in check and streamlines the code flow, error debugging too becomes very easy.
tags: #tester #learning #showdev
canonical_url: https://www.lambdatest.com/blog/syntaxerror-reserved-word/
cover_image: https://www.lambdatest.com/blog/wp-content/uploads/2018/04/RW.jpg
---

Remember when you were a mere beginner in JavaScript, while learning you must have come across the term ‘reserved words’. These are the words that you can’t use as names for variables. Apart from mainstream keywords like break, var, if…else etc. there are many more reserved keywords.
```
SyntaxError: "x" is a reserved identifier  (Firefox)
SyntaxError: Unexpected reserved word (Chrome)
```
Following will be the error messages you will receive if by accident you use such words. Seasoned JS developers too commit such blunders while scripting.

***Do you know [URL addresses](https://www.lambdatest.com/free-online-tools/url-encode?utm_source=devto&utm_medium=organic&utm_campaign=jul07_sd&utm_term=sd&utm_content=free_tools) can only be copied over to the Internet if they use ASCII characters. These addresses contain characters outside the ASCII set, so they must first be converted into an ASCII format. URL encoding replaces unsafe ASCII characters with a percent sign (%) followed by two hexadecimal digits.***

### Strict mode

Strict mode has become a necessity because of its many benefits. It keeps in check and streamlines the code flow, error debugging too becomes very easy. I wouldn’t say that it has shortcomings but you need to be extra careful while implementing this.

In addition to the already existing reserved keywords, Strict mode reserves a few more keywords like _implements, interface, let, package, private, protected, public, as, yield_ and _static_.
```
<!DOCTYPE html>
<html>
<body>

<h2>With "use strict":</h2>
<h3>Using a reserved word as variable name, is not allowed.</h3>

<p>Activate debugging in your browser (F12) to see the error report.</p>

<script>
"use strict";
var public = 'Thanos';  // This will cause an error (public is reserved in strict mode).
</script>

</body>
</html>
```

***Check this out: [Base64 encoding](https://www.lambdatest.com/free-online-tools/base64-encode?utm_source=devto&utm_medium=organic&utm_campaign=jul07_sd&utm_term=sd&utm_content=free_tools)- A way of translating binary data into text form so that it can be transmitted more easily via e-mail and HTML form data.***

![Unexpected syntax error](https://www.lambdatest.com/blog/wp-content/uploads/2018/04/error-report-2.png)

Now we change the variable name to avengerEnemy, now it will work.
```
<!DOCTYPE html>
<html>
<body>

<h2>With "use strict":</h2>
<h3>No reserved word used</h3>

<p>Activate debugging in your browser (F12) to see the avengerEnemy.</p>

<script>
"use strict";
var avengerEnemy = 'Thanos';  //  avengerEnemy is not a reserved word in strict mode.
console.log(avengerEnemy);
</script>

</body>
</html>
```
![error debugging, reserved keywords](https://www.lambdatest.com/blog/wp-content/uploads/2018/04/thanos-showing.png)

***Do you know the [URL Parse](https://www.lambdatest.com/free-online-tools/url-parse?utm_source=devto&utm_medium=organic&utm_campaign=jul07_sd&utm_term=sd&utm_content=free_tools) Online allows splitting up the query string into a human-readable format and takes care of decoding the parameters.***

If you still get the same error, it may be due to the outdated browser version. Try updating the browser, as the old versions have old reserved words that need to be revised.  
Happy scripting!


[![](https://www.lambdatest.com/blog/wp-content/uploads/2018/11/Adword-Cyber2.jpg)](https://goo.gl/4umtgi)