Skip to content

Instantly share code, notes, and snippets.

@getify
Created July 6, 2012 02:58

Revisions

  1. getify revised this gist Jul 6, 2012. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,10 @@
    // you'd ever actually use. don't miss the forest for the trees.
    // Read down in the comment thread for 'myCoolString' for a slightly
    // more sensible example.
    //
    // NOTE #2: this gist thread was spawned from a twitter discussion
    // about `parseInt(0/1,19)==18`:
    // https://twitter.com/getify/status/221009838006747136
    // **********


  2. getify revised this gist Jul 6, 2012. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    // **********
    // NOTE: this is a stupid trivial example illustrating automatic
    type-coercion, not an example of the kind of data-structure logic
    you'd ever actually use. don't miss the forest for the trees.
    Read down in the comment thread for 'myCoolString' for a slightly
    more sensible example.
    // type-coercion, not an example of the kind of data-structure logic
    // you'd ever actually use. don't miss the forest for the trees.
    // Read down in the comment thread for 'myCoolString' for a slightly
    // more sensible example.
    // **********


  3. getify revised this gist Jul 6, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    // **********
    // NOTE: this is a stupid trivial example illustrating automatic type-coercion, not an example of the kind of data-structure logic you'd ever actually use. don't miss the forest for the trees. Read down in the comment thread for 'myCoolString' for a slightly more sensible example.
    // NOTE: this is a stupid trivial example illustrating automatic
    type-coercion, not an example of the kind of data-structure logic
    you'd ever actually use. don't miss the forest for the trees.
    Read down in the comment thread for 'myCoolString' for a slightly
    more sensible example.
    // **********


  4. getify revised this gist Jul 6, 2012. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    // **********
    // NOTE: this is a stupid trivial example illustrating automatic type-coercion, not an example of the kind of data-structure logic you'd ever actually use. don't miss the forest for the trees. Read down in the comment thread for 'myCoolString' for a slightly more sensible example.
    // **********


    var myObj = {
    _val: [10,5,7,9,-1,4,13,6],
    toString: function(){
  5. getify revised this gist Jul 6, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    var myObj = {
    _val: [10,5,7,9,-1,4,13,6],
    toString: function(){
    return Math.max.apply(this,this._val);
    return ""+Math.max.apply(this,this._val);
    }
    };

  6. getify created this gist Jul 6, 2012.
    8 changes: 8 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    var myObj = {
    _val: [10,5,7,9,-1,4,13,6],
    toString: function(){
    return Math.max.apply(this,this._val);
    }
    };

    parseInt(myObj); // 13 ==> this is part of what makes javascript awesome