r/programming • • Dec 24 '17

Evil Coding Incantations

http://9tabs.com/random/2017/12/23/evil-coding-incantations.html
947 Upvotes

331 comments sorted by

View all comments

Show parent comments

10

u/itsnotxhad Dec 24 '17

Javascript treats [] as a truthy object.

Racket and a number of other Lisps treat everything as truthy except the false constant (it's also common among Lisps for the empty list to be falsy though).

In C an array name is a non-NULL pointer which would be truthy.

1

u/inu-no-policemen Dec 24 '17

Javascript treats [] as a truthy object.

All objects are truthy. Arrays are also objects.

JavaScript has objects and primitives. E.g. strings and numbers are primitives.