JavaScript DHTML/Javascript Objects/Array

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

Array join()

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



Concatenate Array with another Array

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



Convert Array to String

    
<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>



Pop an element from Array

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



Reverse an Array

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



shift an Array

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



Sort an Array

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



Splice an Array

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



To Array Source

    
<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>



Unshift array

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