kvz.io

Javascript

  • Published on
    In loosely typed languages such as JavaScript or PHP, using `==` to compare values is bad practice because it doesn't account for type, hence `false == 0 == '' == null == undefined`, etc. And you may accidentally match more than you bargained for. If you want you can limit unintended effects & bugs this may lead to, it's often wise to use `===`. In the process of converting legacy codebases to use these triple equality operators, I find that as a rule of thumb you can almost **always force triple equality** in case of comparing variables against **non-numerical strings**. There's just never a case where you want the text `'Kevin'` to pass for the boolean `true`, or the number `3`. And if that can still happen in your legacy codebase, you'll want to limit those risks rather sooner than later. Even if that breaks things that now accidentally, work.
  • Published on
    If you've written a webapp and you want to ensure that critical parts such as the signup process stay working, the best would be to have an actual user go through that process every time you change your codebase. But since that's both tedious & expensive, the second best thing is to automate a chrome browser (webkit engine anyway) to do this for you, and upload screenshots if anything unexpected happens. Welcome to CasperJS!
  • Published on
    IDs are often numbers. Unfortunately there are only 10 digits to work with, so if you have a lot of records, IDs tend to get very lengthy. For computers that's OK. But human beings like their IDs as short as possible. So how can we **make IDs shorter**? Well, we could borrow characters from the alphabet as have them pose as additional numbers.... Alphabet to the rescue!