fix(curriculum): clarify RangeError example in debugging lecture (#63964)

This commit is contained in:
saimanoharigodavarty
2025-11-19 19:43:22 +05:30
committed by GitHub
parent 014882c92d
commit cce4f57022
@@ -50,14 +50,14 @@ This example will result in a `developerObj.map is not a function` error because
The last common error we will look at is the `RangeError`.
A `RangeError` happens when your code tries to use a value thats outside the range of what JavaScript can handle. Here is an example of trying to assign an invalid index to the length of the array:
A `RangeError` happens when your code tries to use a value thats outside the range of what JavaScript can handle. Here is an example of assigning an invalid value to an array's length:
```js
const arr = [];
arr.length = -1;
```
Since `-1` is not a valid index used for arrays, this will result in a `RangeError`.
Since an array's `length` has to be a non-negative integer, setting it to `-1` triggers a `RangeError`.
As you continue to program in JavaScript, just be aware of these different types of errors you will probably encounter and why they are happening.
@@ -137,7 +137,7 @@ The error happens because the variable is being treated like a function when it'
## --text--
Which error occurs when you try to access an array index that doesn't exist?
Which error occurs when you assign an invalid value, such as `-1`, to an array's `length`?
## --answers--