+ 1

typeOf(func()); in JavaScript ?

function func(){ return 1; } type of func() is function. function func(x){ return x; } type of func(1) is number. type of func('a') is string. .....

1st Nov 2017, 6:17 PM
Abderrahim Oukhrib
Abderrahim Oukhrib - avatar
2 Answers
+ 2
JS expects "typeof" ("typeOf" will get an error). By the way, the first one evaluates because of the parentheses and will be a number. Do you have a question?
1st Nov 2017, 6:33 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
As you can see by your output, it's letting you know the typeof the object in question. func() = a function 1 = a number 'a' = a string
1st Nov 2017, 6:43 PM
AgentSmith