So, this is my function:
function thisismyfunction(myvariable) {
// I do stuff here
}
And then if I wanted to run it, I’d assume something similar to this:
thisismyfunction('foo');
And then the argument is given. But what if it was something like this:
var myobject = new thisismyfunction;
Then how would the argument by given?
UPDATE: It seems that it is possible to instantiate it like this:
var myobject = new thisismyfunction('foo');
But is there another way which still can pass the value in?
If you use
newthen the parenthesis are optional so long as you aren’t passing arguments.If you want arguments (that are not
undefined), then they are required.Re follow up question:
Of course. I just said that.
There isn’t any need for another way.