Thursday, 22 August 2013

What is the simplest way I can check to see if an array has elements or not?

What is the simplest way I can check to see if an array has elements or not?

How can I determine if an array has elements and return false if that
array is not defined?
I have the array modal.questions
I was using modal.questions.length but now this seems to be a problem if
questions is not defined.
Is there a way I can do this using a libray function of _underscore.js or
a simple way I can code a function to make the check?

No comments:

Post a Comment