OutputNot attempted
Return values people forget
const newList = [1, 2, 3].push(4);console.log(newList);console.log(parseInt('7*6', 10), parseInt('12px'), Number('12px'));const obj = { hasOwnProperty: 1, foo: 2 };try { obj.hasOwnProperty('foo');} catch (e) { console.log(e.name);}console.log(Object.hasOwn(obj, 'foo'));Spaces and quote style don’t matter · write a thrown error as TypeError
Ctrl Enter
Show answer & explanation
The expected output comes from actually running the snippet; opening this shows it next to the explanation.
push returns the NEW LENGTH, not the array. parseInt reads digits until the first invalid char ("7*6" → 7, "12px" → 12) while Number() needs the whole string (NaN). An own property can shadow Object.prototype.hasOwnProperty; Object.hasOwn is the safe version.