code: function classList(element) {
          function updateClass(removedClass, addedClass) {
              return (element.className.replace(removedClass, '') + ' ' + addedClass || '').replace(/\s+/,' ');
          }
  
          return {
              add: function (addedClass) {
                  element.className = updateClass(addedClass, addedClass);
              },
              remove: function (removedClass) {
                  element.className = updateClass(removedClass);
              }
          };
      }
docs: Class list