1function processConfig(config) {
2 if (typeof config !== 'object') {
3 throw new Error('Config must be an object');
4 }
5 return config.host + ':' + config.port;
6 // TypeError: Cannot read properties of null
7}
8
9processConfig(null); // should throw, but doesn't
no lines flagged
#034PracticeEasy8 min · 50 XP
typeof null Returns "object"
A null check using typeof passes for null values and crashes downstream code.
Flagged linesNo lines flagged yet
What's wrong?
Flag a line or write a note to submit.