Using custom plugins in javascript

I am able to get the idea that new plugins can be created. How are the newly created plugins called?

For example i can do a _paq.push('trackevent'....) in javascript to call the trackevent function. So, how do i translate the javascript calls to the newly created custom plugin?