It is possible to check if function expect/need any data?
function one(){
}
function two(ineedvar){
}
So i have to functions and I would like to check which of them need var between ().
It is possible to check if function expect/need any data?
function one(){
}
function two(ineedvar){
}
So i have to functions and I would like to check which of them need var between ().
You can use .length
property of the function to see if it takes any argument.
i.e two.length
But note that function can also take arguments
without having it define it in the function declaration, so can't rely on that always.
Use length
property of the Function
object:
one.length /* 0 */
two.length /* 1 */