Utility Class
17/08/2018 — 1 Min Read — In JavaScript, ES6
ES6 TIP: Create utility functions by using static methods, used without instantiating their class.
class SuperTools {
static hasClass(elm, classN) {
return new RegExp('(\\s|^)' + classN + '(\\s|$)').test(elm.classN);
}
static getCssProperty(elm, prop) {
return window.getComputedStyle(elm, null).getPropertyValue(prop);
}
}
SuperTools.hasClass(elm, 'class-name');