I have two JS files (functions.js and app.js)
functions.js - contains a big amount of functions ( so putting them together with app.js - isn't best option ). The regular and arrow functions can be passed with import * as funcs from './functions' or import {func1, func2, func3, ...} from './functions',
but when I get to the functions with .prototype ( Array.prototype/ HTMLElement.prototype ) I don't know how to execute them.
Example for a function:
HTMLElement.prototype.findRect = () => {
console.log("CODE HERE...")
}
Someone has an idea how to pass those functions?
These are almost like a global function, it needs to be executed once, but after that, you don't have to keep calling it.
Say a file 'abc.js',
ABC.prototype.go = () => {}
In another file app.js
import 'abc.js'
const a = new ABC()
a.go()
These prototype is the methods that you can dynamically add to the class ABC. Here ABC is a class such as HTMLElement, Array and etc. You can't invoke them directly, instead you can invoke any instance after you create one out of this class.