Javascript, The Bad Parts

By Daniel Huckstep

verboselogging.com

@darkhelmetlive

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.

parseInt

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?

with

You're being trolled by the property lookup chain.

Make code less readable and slower.

Why is it a good thing again?

eval

Can you spell slow security hole?

Minimizers hate eval too.

setTimeout/setInterval

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.

wat.

Thanks everybody

View Online