Answer the question
In order to leave comments, you need to log in
How to format helper functions correctly?
Hello,
I want to create my own helper functions, something like:
/* helpers.js */
function find( el, selector ) {
return el.querySelector( selector );
}
function on( el, event, callback ) {
el.addEventListener( event, callback );
}
/* helpers.js */
abc.find = function( el, selector ) {
return el.querySelector( selector );
}
abc.on = function( el, event, callback ) {
el.addEventListener( event, callback );
}
Answer the question
In order to leave comments, you need to log in
el.find( selector ), just like jQuery does.
String.prototype.customFunction = function () {
console.log('кастомная функция');
};
let a = 'test';
a.customFunction();
"test".customFunction();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question