What is the C# " public void (name) " equivalent in JS?

Hi,

In C# I like making buttons by assigning my actions inside public void(), for example:

public void (demo)
{
//on button click use this so my stuff will happen here
}

However now I’m working with a JS (and I have no knowledge is JS, only C# and some Java. So how do you do this in JS?

THANK YOU!

function Demo()
{
// do stuff
}