remove element from array with no gap - Javascript jQuery

Javascript examples for jQuery:Array

Description

remove element from array with no gap

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//  www.j  a va 2 s. c o m
var myList = [];
myList.push({my: "my0"});
myList.push({my: "my1"});
myList.push({my: "my2"});
console.log(myList);
console.log(remove(myList,1));
function remove(arr, index){
    arr.splice(index,1);
    return arr;
}
    });

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials