Know if a variable is a native object in javascript

Posted by mck89 on Stack Overflow See other posts from Stack Overflow or by mck89
Published on 2010-05-12T14:21:08Z Indexed on 2010/05/12 14:24 UTC
Read the original article Hit count: 398

Filed under:
|
|
|

Hi, is there a way to know if a variable passed into a function is a native object? I mean, i have a function that requires only native objects as arguments, for every other type of variable it throws an error. So:

func(Array); //works
func(String); //works
func(Date); //works
func(Object); //works
...
func([]); //Throwr error
func({}); //Throws error

I want to know if there's a way to distinguish between native objects and everything else.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about native