JavaScript Tutorial/Array/toSource — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:25, 26 мая 2010

Array.toSource()

The toSource() method returns one string representing the source of the Array object.

The string contains all the elements in the array separated with commas.

The entire string is enclosed with brackets ([]).

If another array is contained within an array, its contents are also part of the string with its own set of brackets.



<html>
    <script language="JavaScript">
    <!--
    numbers = new Array(3,6,7);
    colors = new Array("Blue","Green","Red",numbers);
    aString = colors.toSource();  
    document.write(aString); 
    -->
    </script>
</html>


Two dimensional array toString

<html>
    <script language="JavaScript">
    <!--
    numbers = new Array(3,6,7);
    colors = new Array("Blue","Green","Red",numbers);
    aString = colors.toSource();  
    document.write(aString); 
    -->
    </script>
</html>