A JavaScript question

i have a question, when you learn functions in JavaScript in codecombat, you learn how to define functions for hero like this

hero.justAFunction = function(parameter1,parameter2)
{
    //do something
};

can we define functions for other things?, like for example arrays, or units, if we can, how???