JavaScript DHTML/Javascript Objects/Array

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

Array join()

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(10,11,12);

                alert(myA.join("---"));">Array: JOIN</button>

</body> </html>


     </source>
   
  


Concatenate Array with another Array

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(10,11,12);

                alert(myA.concat(13,14,15));">Array: CONCAT</button>

</body> </html>


     </source>
   
  


Convert Array to String

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(0,1,2,3,4,5);

                alert(myA.toString());">call Array TOSTRING</button>

<button onclick="var myDate = new Date(); alert(myDate.toString());"> call Date toString</button> </body> </html>


     </source>
   
  


Pop an element from Array

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(10,11,12); myA.pop(); alert(myA);"> Array: POP </button> </body> </html>


     </source>
   
  


Reverse an Array

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(10,11,12); myA.reverse();

                alert(myA);">Array: REVERSE</button>

</body> </html>


     </source>
   
  


shift an Array

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(10,11,12);

                myA.shift(); 
                alert(myA);">
                Array SHIFT
                </button>

</body> </html>


     </source>
   
  


Sort an Array

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(1,15,13,11,2,4,16); myA.sort(); alert(myA);"> Array sort </button> </body> </html>


     </source>
   
  


Splice an Array

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(10,11,12,13,14,15); alert(myA.splice(1,3));"> Array splice </button> </body> </html>


     </source>
   
  


To Array Source

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(10,11,12,13,14,15);

                alert(myA.toSource());">Array TOSOURCE</button>
                
                

<button onclick="var myDate = new Date(); alert(myDate.toSource());"> Date toSource </button> </body> </html>


     </source>
   
  


Unshift array

   <source lang="html4strict">
   

<html> <body> <button onclick="var myA = new Array(10,11,12); myA.unshift(14); alert(myA);"> unshift </button> </body> </html>


     </source>