Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Ryan 2

<!DOCTYPE html>
<html>
<head>
<title>Sample</title>
<script>
function main(){
    /*     */
    var ary = ["banana", "mango", "watermelon", "apple"]; 
    
    var str1 = ary.toString(); 
    document.write("Comma-separated String: "+str1+"<br>"); 
    /*at 2, delete nothing */
    ary.splice(2, 0, "cherry"); 
    str1 = ary.toString(); 
    document.write("After splice(2, 0, \"cherry\"): "+str1+"<br>"); 
    /* at 3, delete 2*/
    ary.splice(3, 2); 
    str1 = ary.toString(); 
    document.write("After splice(3, 2): "+str1+"<br>");
    ary.splice(1,1);
    str1 = ary.toString();
    document.write("After splice(1,1): "+str1+"<br>");
  }
</script>
</head>
<body onload="main()">
</body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.