Since the add()
method from the classList
just allows to pass separate arguments and not a single array, you need to invoque add()
using apply. For the first argument you will need to pass the classList
reference from the same DOM node and as a second argument the array of classes that you want to add:
element.classList.add.apply(
element.classList,
['class-0', 'class-1', 'class-2']
);