Which fix removes the bug?
function walk(value) {
if (typeof value === 'array') {
value.forEach(walk);
}
}
- Test
typeof value == 'array' - Test
typeof value === 'list' - Use
Array.isArray(value) - Use
value instanceof Object
typeof returns 'object' for arrays, so the branch never runs.
Play Problem Solving ▸