100 words 12

I just spent an hour or so debugging some JavaScript.

The code was simple, concatenate a string to form a selector: '#in-category-' . termId. Undefined. Always undefined.

I started dumping all sorts of things in the console to debug. termId was defined. The code was passing through conditional statements correctly.

I was just about to send the diff to my work mate Dzikri with the note “this is the general idea but I’ve made a silly mistake” when I saw it.

I was using PHP style concatenation in JavaScript.

I’ve noticed this immediately in people’s code. I’m sure you did too.

Leave a Reply

Your email address will not be published. Required fields are marked *