Hello,
I'm trying to build my application as OOP, that's why I have parted all classes in different files. I have placed those files in modules directory.
Example ;
modules/connectionClass.js
var connectionClass=function(){ getVars=function(){ return {social_id:Math.floor((Math.random() * 4)),text:zeroFill(Math.floor((Math.random() * 10) + 1),6)} }; }
modules/helper.js
function zeroFill( number, width ) { width -= number.toString().length; if ( width > 0 ) { return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number; } return number + ""; // always return a string }
projects/main.js
require('connectionClass'); var connection=new connectionClass();
But at the line var connection=... I'm getting this error
Uncaught Error: Field or method does not already exist, and can't create it on undefined at line x col y
What I am doing wrong?
@fobus started
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.
Hello,
I'm trying to build my application as OOP, that's why I have parted all classes in different files. I have placed those files in modules directory.
Example ;
But at the line var connection=... I'm getting this error
What I am doing wrong?