how do i check if a specific array exists, and if not it will be created?
Tell me more
×
Stack Overflow is a question and answer site for
professional and enthusiast programmers. It's 100% free, no registration required.
If you want to check whether an array x exists and create it if it doesn't, you can do
|
|||||||||||||
|
|
|||||||||||||||||
|
You can use the
|
|||||||
|
If you want to check if the object is already an Array, to avoid the well known issues of the
|
|||||||||
|
If you are talking about a browser environment then all global variables are members of the window object. So to check:
|
|||
|