[Solved] JavaScript equivalent of PHP passing parameter


Neither of the two are correct. In PHP var1 will get that value in the function. In JS, if you don’t want to assign something to the first parameter, make it null.

do_it(null, 'something_cool');

And then inside the function, check if it’s null and perhaps give it a default value if it is. Or just reorder them so you don’t have to. In JS you can pass any number of parameters into a function.

solved JavaScript equivalent of PHP passing parameter