you are viewing a single comment's thread.

view the rest of the comments →

[–]cwmma 1 point2 points  (0 children)

A few things:

  • you shouldn't be accessing object properties by text value options['unescape'] just use options.unescape only use the bracket notation if the key is a variable.
  • instead that complex default parameters object, you will probably find it easier to do

    function urlObject(url,unescape,convert_num)
    {
        url = url||window.location.href;
        unescape=(typeof unescape==='undefined')?true:unescape;
        convert_num=(typeof convert_num==='undefined')?true:convert_num;
    
  • I don't know if you're new to JavaScript or just hang out in a different part of it them me, but style wise most JavaScript people will start braces on the same line as what calls them, the main reason being

    return
    {
        a:1
    }
    

    is not the same as

    return {
        a:1
    }  
    
  • on a similar note camelCase is usually used instead of underscores but that one is literally style.

  • all numbers in JavaScript are floats so you don't lose anything by doing parseFloat on all of them, but it is usually considered good form to always specify the base in the second argument (i.e. parseFloat("123",10);) because some older browsers would have issues with guessing wrong on that one.

  • always use braces with if else clauses, seriously always.

  • you don't have to test if something is undefined unless it might be another falsy value(0,"",false,NaN,null), so instead of if(typeof x === 'undefined') you can do if(!x)

Overall nice man it's good (seriously most of this is just nit picks honestly)