Home » Javascript » No need to declare types in parameters in javascript?

No need to declare types in parameters in javascript?

Posted by: admin October 29, 2018 Leave a comment

Questions:

I noticed while learning javascript that it does not require you to declare types in the parameter of a function like java does. How does the compiler know what type is passed? is there any type checking? Lets say my function handles numbers instead of strings and I pass a string?

Also normally in javascript do you not need to specify in the parameters that you are passing a function? Again how does the compiler know?

function invokeAdd(a,b){
return a()+b();
}
Answers: