Jared
Jared

Reputation: 1793

How to get total number of variables in an array in Javascript?

Google wasn't my friend on this one... maybe I wasn't searching for the right terms.

I have a javascript array randomTagLine[0], randomTagLine[1], etc. How do I get the total number of variables in the array? For instance, I can physically see there are 23, but I need to pull that out via JS code...

Thanks in advance..

EDIT

Example of code:

var randomTagline = new Array();
randomTagline[0] = "TEXT0";
randomTagline[1] = "TEXT1";
randomTagline[2] = "TEXT2";
//...
randomTagline[23] = "TEXT23";
var randomTaglineLength = randomTagLine.length;

var randomTaglineNum = randomXToY(0,randomTaglineLength,0);

alert(randomTaglineNum + " " + randomTaglineLength);

Upvotes: 1

Views: 737

Answers (1)

3rgo
3rgo

Reputation: 3153

It's :

 var length = randomTagLine.length;

Upvotes: 5

Related Questions