Javascript, The Bad Parts

By Daniel Huckstep


All sorts of bad things happen when you use the bad parts

Like bugs. And nobody likes bugs.

Global Variables

You're being trolled by the environment

Block Syntax, with no Block Scope

Every other language you'd want to use has block scope.

But not Javascript.

Automatic Semicolon Insertion

You're being trolled by the interpreter

Characters are 16-bits

You're being trolled by the locale

Need more than 16-bits for a character? Cool story bro.


It takes an extra argument you know...

+ operator

Adding or concatenation, depending on the arguments

If the arguments are different, it does some coercion. Because that's probably what you want.

typeof NaN === "number"

Think about that.

typeof [] === "object"

Javascript arrays are just weird objects.

for-in loops don't really work.

== and ===

Do you want bizarre coercion or an actual equals operator that works as you expect it to?


You're being trolled by the property lookup chain.

Make code less readable and slower.

Why is it a good thing again?


Can you spell slow security hole?

Minimizers hate eval too.


They can take strings, which is just as bad as eval.

case fallthrough

Fallthrough is default, have to use break

Ruby does it right (no fallthrough or break at all), so does Go (explicit fallthrough)

if/while/etc don't require braces

Go finally does this right.

bitwise operators

Convert internally to int, do the operation, then back to float.


Thanks everybody

View Online