1. Day 1/100 Addendum

    Came up with another way to do the RPN calculator by attaching functions in a JavaScript "dictionary":

    // jshint esversion: 6
    
    function add(p) {
        return p.x + p.y;
    }
    
    function multiply(p) {
        return p.x * p.y;
    }
    
    function subtract(p) {
        return p.x - p.y;
    }
    
    function divide(p) {
        return p.x …
    read more
  2. Stupid JavaScript Tricks

    > bar = ['width', 'height']
    [ 'width', 'height' ]
    > bar
    [ 'width', 'height' ]  // Nothing up my sleeve
    > bar.indexOf['length']
    1  // Presto!
    

    In case you haven't guessed what's up here: JavaScript automatically surfaces a value called 'length' in all arrays. So you can get the length of bar by typing bar.length and bar['length' …

    read more

links

social