A common problem when doing value comparison inside of Javascript is the automatic type conversion that happens for you, this means all the following statements resolve to “true”.
- 1 == 1;
- 1 == ‘1’;
- 1 == “1”;
As a little bonus snippet in a post by Steve Wellens he provides an answer to the problem, the triple equals (“===”) and it’s corresponding, not equal (“!==”). These comparison operators perform a type check as well as a value check. This means that a string value will no longer equal it’s corresponding numeric value as the type check will return false. A useful bit of functionality to have.
Just a note about TypeScript Playground, an online REPL for TypeScript. Been around a while, but really useful for trying out a quick bit of TypeScript.
I’ve started playing with the JavaScript SVG library RaphaelJS. It looks a really nice library but the very first hurdle I came across was how to set the background colour of the paper. There didn’t seem to be any help in the documentation and trying ‘paper.attr(“fill”, “#f00”);’ resulted in the error Uncaught TypeError: Object #<a> has no method ‘attr’. A less than optimal solution might be to create a rectangle on the paper that is . . .