@ceremcem, in mentioned post I cover amost to the T what you are looking for: a module that defines a class with method(s) to use JavaScript in an object-oriented way rather than script way: the first - something()function defines the class, and the hello() function a method on the instances of something - instances crated with new something(...), as you state on stackoverflow post. Btw - for the sake of useful convention(s), class names start with a capital letter... ;-).
The solution can happen even in one file or even in two files. Let's look at each option in a separate post.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@ceremcem, in mentioned post I cover amost to the T what you are looking for: a module that defines a class with method(s) to use JavaScript in an object-oriented way rather than script way: the first -
something()
function defines the class, and thehello()
function a method on the instances of something - instances crated withnew something(...)
, as you state on stackoverflow post. Btw - for the sake of useful convention(s), class names start with a capital letter... ;-).The solution can happen even in one file or even in two files. Let's look at each option in a separate post.