Solution Review: "strict" Mode
Explore how JavaScript strict mode changes error handling and the behavior of the this keyword in functions. Understand why strict mode throws errors on illegal property modifications and how it affects function calls, helping you prepare for interview questions on this topic.
We'll cover the following...
We'll cover the following...
For the code above, you had to answer the following question.
Explanation #
Let’s run the code to see what happens.
As you can see, an error is thrown when the code is run; this means Option A is correct. Why do you see an error?
The answer might seem obvious; since, on line 3, when we define the property x, we set its writable property to false; this means it is a read-only property.
On ...