<script>
function add()
{
const ele = document.getElementsByClassName("myclass");
each= []['forEach'];
HTMLCollection.prototype.forEach = each;
ele.forEach(show);
}
function show(q)
{
console.log(q);
}
</script>
</head>
<body>
<button id="btn" onclick="add()">Press </button>
<div class="myclass" id="a">aaaa</div>
<div class="q" id="b">bbbb</div>
</body>
</html>