Some of the reserved keywords are await, const, else, false, finally, if, import, int, new, let etc.
When used reserve keyword as a variable, function name, or labels then it throws an error.
let name = “Startup”;
Then, we print the value of name variable using console log.
console.log(name); // “Startup”
let throw = “JS”;
Finally, we are printing the value of the variable throw using the console log. Any idea what should be the output of the above statement.
Now, you know the answer is “Error“. But why it just a normal variable. Let explain.
So, as firstly we used a name variable which is not a reserved keyword. That’s why no issue.
But in second variable, which is throw variable and throw is a reserved keyword. So, it can not be used as a variable name.
At last, That’s why we get an answer “Error“.
Let me know in the comment section, what you think about it.
I hope you understand the concept and logic behind it.
But wait, i have something more for you –
- JS Quiz – compare the self value with data type
- JS Quiz – can NaN be really equal to NaN
And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page
If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.