I'm trying to get all elements of a class name into an array so that I can map over them and add a new class. The issue I have is when I run the following in my code editor:
var a = document.getElementsByClassName('commissioner-profile-container');
and try to turn the array-like object it returns into an array by then running:
var b = Array.prototype.slice.call(a, 0);
var a will print to the console as the array-like object, but var b prints as simply an empty array.
However, when I do run both of these straight into the console with the page open, they work:
Any idea as to why this is?