Please login to start chat

ICT Solutions 13 Jun 2022, 19:48:42
Category : JavaScript Tutorials

unshift (JavaScript Array Method)

const tnwNames = ["Moe", "Soe", "Noe", "Mya"];
function tnwFun1(){
document.getElementById("demo").innerHTML = tnwNames.join(", ");
}

function tnwFun2(){
document.getElementById("demo").innerHTML = "The original array is : " + tnwNames.join(", ");
let tnwNewvalue = document.getElementById("newname").value;
tnwNames.unshift(tnwNewvalue);
document.getElementById("demo1").innerHTML = "The new array is : " + tnwNames.join(", ");
}

To see demo

Comments:

No comment to show.

Available Services
Download Android Application