QP School

Full Version: JavaScript Array fill() method examples
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
const fruits1 =
      [
        "Banana",
        "Orange",
        "Apple",
        "Mango"
      ];

document.getElementById("demo1").innerHTML = fruits1.fill("Kiwi");

const fruits2 =
      [
        "Banana",
        "Orange",
        "Apple",
        "Mango"
      ];

document.getElementById("demo2").innerHTML = fruits2.fill("Kiwi", 2, 4);