Switching to class system in JS