Way2tutorial Snippet Editor
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript splice() method - delete array element</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> var domain = new Array(".com", ".net", ".org", ".gov"); domain.splice(4, 0, ".int"); // add new elements on indexes 4th document.writeln( domain ); // [".com", ".net", ".org", ".gov", ".int"] domain.splice(4, 1); // remove one elements after indexes 4th document.writeln( domain ); // [".com", ".net", ".org", ".gov"] </script> </pre> </body> </html>