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

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

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

Array.valueOf()

The valueOf() method returns the primitive value of the object.

This method returns the array elements separated by commas.

If an array contains another array, the contents are flattened when this method is used.



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


Use array.valueOf with a two dimensional array

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