Please login to start chat

ICT Solutions 13 Jun 2022, 19:47:15
Category : JavaScript Tutorials

splice (JavaScript Array Method)

const tnwNames = ["Hla", "Mya", "Soe", "Moe", "Noe"];

function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNames.join(", ");
}

function tnwFun2(){
document.getElementById("demo").innerHTML = "The original array is :
" + tnwNames.join(", ");
let result = tnwNames.splice(2, 2, "Aung", "Kyaw", "Tun");
document.getElementById("demo1").innerHTML = "The removed elements are :
" + result.join(", ");
document.getElementById("demo2").innerHTML = "The new array is :
" + tnwNames.join(", ");
}

Comments:

No comment to show.

Available Services
Download Android Application