2

I'm trying to check is p array or not. Am I trying to check true or where am i my making mistake. Actually now i'm learning jQuery.isArray. I think I make mistake in my code but i do not know where. Thank you

var p = ['foo',''];

if(!$(p).isArray()){
  alert('no');
}else{
  alert('yes');
}

FIDDLE

1
  • $.isArray is an utility function and not a dom element method and they should be used as @Rajaprabhu Aravindasamy demonstrated in his answer. The way you used is for dom elements method such as on, hide, remove, ... Commented May 17, 2014 at 10:24

1 Answer 1

4

You have to pass that array as a parameter in to the $.isArray() function.

Try,

if(!$.isArray(p)){
  alert('no');
}else{
  alert('yes');
}

DEMO

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.