thisago's blog


JS Sucks

Table of Contents

Null is object

An key/value object is an object. Right.

return typeof {}
object

Array is object. Fine.

return typeof []
object

Undefined is a special type. Alright.

return typeof undefined
undefined

But null, is object. Damn.

return typeof null
object

Implicit pointers

{} is a empty object, and JS compares the pointers, not its values. Since the language doesn't provides explicit pointers, the result is unexpected.

return {} == {}
false

0-based index for month

Day is 1-based index, but month is 0-based. We're using month 1 and getting month 2

return new Date(2000, 1, 1).toISOString()
2000-02-01T02:00:00.000Z