0

so far I found these,

  • using RegExp
  • using typeof
  • using Object.prototype.toString.call(arg)

which way is better in term of performance ?

  • What's wrong with `typeof` the leads you to those hacks? – haim770 Mar 16 '16 at 07:57
  • 1
    If you don't need to distinguish between different objects, using `typeof` is the prefered way to do it. I do not see any reason to use another method. – henrikmerlander Mar 16 '16 at 07:58
  • 1
    They do very different things. So if you don't tell us what you need (why you need to check variable types, in what use case?) we can't tell you which one to choose. In terms of performance, no type check is always the best. – Bergi Mar 16 '16 at 08:03

0 Answers0