News for hackers. Stuff that matters.
Re:Null is an Object in JavaScript by readthenotes1 on Wednesday February 08, 2023 @01:37AM (#34704892)
"The difference between a bug and a feature is longevity."

  -said by someone last millennium
Re:Null is an Object in JavaScript by bryanrasmussen on Wednesday February 08, 2023 @03:49AM (#34705735)
that's wrong, but it's been around so long I guess we have to accept it.
Re:Null is an Object in JavaScript by abdnafees on Wednesday February 08, 2023 @04:34AM (#34706021)
After asking the question, I looked for an answer and found the is-object npm package. It utilizes a null check to make sure a variable is an object. This utility has 6.6 million weekly downloads. The logic in the isObject function will break because the second condition would then be invalidated. Resulting in a bad day for 6.6 million projects. It took me a while to digest the magnitude. Maybe because I just started as an SWE.
Re:Null is an Object in JavaScript by andrewmackrodt on Wednesday February 08, 2023 @04:46AM (#34706113)
If a language change were to update `typeof null` to return `"null"` isObject would not break, the second condition would only be unnecessary.

However, other code which may make assertions on null values after checking the value is an object would break.

Re:Null is an Object in JavaScript by white_dragon88 on Wednesday February 08, 2023 @06:53AM (#34706905)
Well it’s supposed to pose a philosophical argument. A related phrase might be ‘perfect is the enemy of good’, etc