array object
array object
JavaScript-II 477
var link = new Array ("first.html ", "Becond.html ",
var llnk = tElret.html n, "second. html "
"third.html
var link =(x,Y, z] t / /Here x="flret . html ",y= "second.htmi "and nthird.h"third,
"1;
z tmlu ):
NOTE: Accessing an array element whose value is not specificd will return undefined value.
Some of the commonly used properties and methods associated with Array object :
are
PROPERTY DESCRIPTION
</script>
</body>
</html>
On viewing the webpage in a web browser you will get the desired output.
Program 17 : Script to display multiple messages one at a time after specific interval
such that when you click the button, a link corresponding to that message
is displayed.
<html>
<head><title>Links and Arrays </title></head>
<body>
<table border = "0">
<tr><td>
<formn name "£rm">
<textarea rows = "5" name = "info" cols= "30"></textarea><br>
<input type = " button" value - "Click to get more" onclick =
"window. location = msg [current ]">
</form>
</tâs</tr>
</table>
<8cript
<!-
language = "JavaScript">
JavaScript-I 479
1ink [1] = "http://www.microsoft.
1ink [2] - "http:/ /www.download.com":
function showmsg ()
{
if (current <msg.length-1)
Current ++;
else
Current 0;
ocument. frm. info.value = msg [currentl;
setTimeout ("showmsg() ", 2000):
}
showmsg ( )i
</script>
</body>
</html>
P
On viewing the webpage in aweb browser, you will be displayed three different messegs
at aregular intervals in atext box, on clicking the button, the corresponding link willopen.
number
ASSOCIATIVE
array andthe text ARRAY
18.18
instead
and canAssociative
var
persOn persOn
person the be
of
valuedefinednumbers.
disadvantage that is
["age"] [" arrays
can
name as
benew = The are
"]
assigned
= similiar
main
40;
Array );(
" advantage
Ankur" ; as youcannot to
regular
of
array
access
using
with
values that it
the
the
difference
using
string
the
numbers are that
easier the
index
in to
rememberthan
Associ
loop.a a value
ront