‹ Sid Verma

Tags / Javascript


A follow up to my previous post, this time we look into some of the lesser known, but widely used javascript packages.

Javascript’s NPM package manager, is one of the biggest and fastest growing package manager out there. As of writing this:

  • RubyGems - 145,675 (25 new packages/day)
  • PyPI - 149,111 (104 new packages/day)
  • Packagist - 191,577 (103 new packages/day)
  • Maven Central - 244,143 (149 new packages/day)
  • npm - 679,009 (508 new packages/day)

Minimalism doesn’t only apply to design, lifestyle and ownership, but also to code. Here are some of the most minimal packages in npm:

All of these were executed on Node.js 6.9.1

> [] + []
''

Obviously.

> [] + {}
'[object Object]'

Less obvious, but okay.

> {} + []
0

Huh?

> {} + {}
'[object Object][object Object]'

Oh, fuck off.

I’d rather just add strings to these from now on:

> [] + ''
''
> [] + '1'
'1'
> [] + 'a'
'a'
> {} + ''
0
> {} + '1'
1
> {} + 'a'
NaN

Lol.

Okay, subtraction maybe:

> [] - []
0
> {} - {}
NaN
> [] - ''
''
> [] - '1'
-1
> [] - {}
NaN

FML.

But, my favorite one is this:

> {} - []
-0

Follow-up post: Minimalistic javascript packages

« Older posts Newer posts »