Search code examples
javascriptjqueryprogramming-languages

correct function parameters designation


Every time i pass some parameters to a JavasScript or jQuery functon, i use some random letters. What are the correct letters for the corresponding variable types?

function(o){} for example is for a object. But what are the other letters? Do someone have a list of those?


Solution

  • Here is a good list of letters I could think of:

    o - object
    a - array
    s - string
    d - date
    n - number
    r - regexp
    b - boolean
    

    But seriously, jokes apart, I think you might be mixing up the packed/minified source with the actual source that developers write. For example, this little function looked like this originally:

    function myFunction(personName) {
        this.name = personName;
    }
    

    But after minifying, it becomes:

    function myFunction(a){this.name=a}
    

    packer is one such utility by Dean Edwards that will minify your Javascript. Play with your source code at this website and see the compressed output. Check the Shrink variables option on the right to see how parameters and other variables get renamed.

    This however shouldn't affect how you write your code at all. Be it Javascript, or any other language, all identifiers - variables, function names, class names, etc. should be named after what they represent or do rather than obscure shorthands.