SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 100 | Next

Robin Pars, Laurence Moroney, and John Grieb

"Foundations of ASP.NET AJAX"


You still need to have a ScriptManager control on your page to use any of these JavaScript
type extensions.
Array and Boolean Extensions
Arrays are nothing new in JavaScript, but the added extensions in the ASP.NET AJAX
libraries make them a whole lot more functional and similar to those available in the
.NET Framework. Of course, these are not going to be exactly identical in signature and
behavior to the Array object of the .NET Framework. Another important point to note is
that the methods of the Array extension are provided as helper methods for an existing
JavaScript Array object, and thus using them does not require instantiation in a similar
55
C H A P T E R 4
manner to static methods. Therefore, you can start using the methods without having to
instantiate the Array extension itself. Table 4-1 lists the methods of the Array extension.
Table 4-1.Methods of the Array Extension
Method Name Description
add Adds an element to the end of an array
addRange Copies all elements of one array to the end of another array
clear Deletes all elements of an array
clone Creates a shallow copy of an array
contains Boolean value indicating whether or not an element is in an array
dequeue Deletes the first element of an array
enqueue Another method for adding an element to the end of an array
forEach Iterates through the elements of an array
indexOf Returns the index of a specified element in an array (returns -1 if the
element wasn??™t found in the array)
insert Inserts a value at a specified location in an array
pars Creates an Array object from a string variable
remove Removes the first occurrence of an element in an array
removeAt Removes an element at a specified location in an array
To better understand these methods and how they can be used, consider the following
JavaScript snippet: