Tuan-Anh Tran

How to code like a dick in JS

Posted on May 11, 2014  •  1 minutes  • 140 words

The goal of this post is to make simple things look complicated.

1. Invert logic

Let’s start with something easy.

Instead of

if (x && y) { ... } // easy

Write this instead

if (!(!x || !y)) { ... } // good enough

2. Extended unicode chars for variable names

Use of extended unicode chars, especially those that are not visible in console like \r, \t, etc…

3. Use = instead of ==

if (x=true) { ... } // always executed

Do this when you want to always excute that code block. Someone may see this and will attempt to “fix” it on their own, changing the original logic. Goodluck debugging it later : )

4. Use 8-base or n-base instead of decimal base

Because why not?

var x = 19;   // 19
var y = 019;  // 17
Follow me

Here's where I hang out in social media