aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to know a variable is an array or not in Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to know a variable is an array or not in Javascript" Watch "How to know a variable is an array or not in Javascript" New topic
Author

How to know a variable is an array or not in Javascript

Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Thanks very much.


truehh@hotmail.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

You're welcome.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
In my website,say "names" could be just a string variable,or it could a string array .

Here I want to know when "names" is an array,when it is only a string variable.

Any ideas?
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Sorry,guys,another question is how to know whether a element exists or not?
say,

var testElement = document.myform.firstinput

sometimes the firstinput does not exist,so "testElement" will be undefined.
how do i know it,is there a function to test it?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
look into typeof

Eric
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
Thanks very much.typeof is great!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to know a variable is an array or not in Javascript