which is the most secure way to check variables type javascript
- by mck89
Hi, i need to check the type of a variable in javascript, i know 3 ways to do it:
instanceof operator: if(a instanceof Function)
typeof operator: if(typeof a=="function"
toString method (jQuery uses this): Object.prototype.toString.call(a) == "[object Function]"
Which is the most secure way to do type checking beetween these solutions? and why? Please don't tell me that the last solution is better only because jQuery uses that.