JavaScript Example (Program)
Learn Details

Q. Where do use push() method ?

जिस array के last element (value) के बाद Single या multiple element को insert (add ) करना हो , तब push method का use करते हैं

ArrayName.push(item1, item2, ..., itemX)

  • Example


    <script>
    var a = ["Apple", "Ball", "Cat", "Dog"];
    document.write("<b> Before Medhod : </b>" +  a+"<br>");
    a.push("Elephant")
    document.write("<b> After Medhod : </b>" +  a);
       
    </script>
    Out Put : Before Medhod : Apple,Ball,Cat,Dog
    After Medhod : Apple,Ball,Cat