Skip to main content
added 35 characters in body; edited tags; edited title
Source Link
Oleg V. Volkov
  • 22.6k
  • 4
  • 49
  • 68

in javascript how How to find elementcheck that value is an array  ?

In javascript isIs there a good(i mean built in)-in way that iI can find whether element ifvalue is a array ofor not  ? one

One simple icheck I can seethink of is as follows, but iI don't like it:

if(ele.push){/ /* its array it has push method :)*/ }

I mean i would like know if something like pseudo-code below if exists. typeof made me upsettypeof doesn't seems to be applicable, as its returningit only returns "object" (though that makes sense).

function x(ele){ if(isArray(ele)){/ /* dosomething() */ } }

in javascript how to find element is array  ?

In javascript is there a good(i mean built in) way that i can find whether element if array of not  ? one simple i can see is as follows but i don't like it

if(ele.push){//its array it has push method :) }

I mean i would like know if something like below if exists. typeof made me upset as its returning "object" (though that makes sense)

function x(ele){ if(isArray(ele)){//dosomething} }

How to check that value is an array?

Is there a good built-in way that I can find whether value is a array or not?

One simple check I can think of is as follows, but I don't like it:

if(ele.push){ /* its array it has push method */ }

I mean i would like know if something like pseudo-code below exists. typeof doesn't seems to be applicable, as it only returns "object" (though that makes sense).

function x(ele){ if(isArray(ele)){ /* dosomething() */ } }
added 81 characters in body
Source Link
Anil Namde
  • 6.6k
  • 12
  • 68
  • 101

In javascript is there a good(i mean built in) way that i can find whether element if array of not ? one simple i can see is as follows but i don't like it

if(ele.push){//its array it has push method :) }

I mean i would like know if something like below if exists. typeof made me upset as its returning "object" (though that makes sense)

function x(ele){ if(isArray(ele)){//dosomething} }

In javascript is there a good(i mean built in) way that i can find whether element if array of not ? one simple i can see is as follows but i don't like it

if(ele.push){//its array it has push method}

I mean i would like know if something like below exists

function x(ele){ if(isArray(ele)){//dosomething} }

In javascript is there a good(i mean built in) way that i can find whether element if array of not ? one simple i can see is as follows but i don't like it

if(ele.push){//its array it has push method :) }

I mean i would like know if something like below if exists. typeof made me upset as its returning "object" (though that makes sense)

function x(ele){ if(isArray(ele)){//dosomething} }
Source Link
Anil Namde
  • 6.6k
  • 12
  • 68
  • 101

in javascript how to find element is array ?

In javascript is there a good(i mean built in) way that i can find whether element if array of not ? one simple i can see is as follows but i don't like it

if(ele.push){//its array it has push method}

I mean i would like know if something like below exists

function x(ele){ if(isArray(ele)){//dosomething} }