Reputation: 11221
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 ().
Upvotes: 1
Views: 64
Reputation: 123739
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.
Upvotes: 6
Reputation: 1060
Use length
property of the Function
object:
one.length /* 0 */
two.length /* 1 */
Upvotes: 2