InterviewSolution
| 1. |
What Is Undefined X 1 In Javascript? |
|
Answer» var trees = ["redwood","bay","cedar","oak","MAPLE"]; delete trees[3]; When you RUN the code above and type console.log(trees); into your Chrome developer console, you will GET ["redwood", "bay", "cedar", undefined × 1, "maple"]. When you run the code in Firefox's browser console, you will get ["redwood", "bay", "cedar", undefined, "maple"]. Thus, it's CLEAR that the Chrome browser has its own way of displaying uninitialised indexes in arrays. However, when you check trees[3] === undefined in both browsers, you will get similar output as true. var trees = ["redwood","bay","cedar","oak","maple"]; delete trees[3]; When you run the code above and type console.log(trees); into your Chrome developer console, you will get ["redwood", "bay", "cedar", undefined × 1, "maple"]. When you run the code in Firefox's browser console, you will get ["redwood", "bay", "cedar", undefined, "maple"]. Thus, it's clear that the Chrome browser has its own way of displaying uninitialised indexes in arrays. However, when you check trees[3] === undefined in both browsers, you will get similar output as true. |
|