xxxxxxxxxx
Invalid cases
const Car = 1;
new Car();
// TypeError: Car is not a constructor
new Math();
// TypeError: Math is not a constructor
new Symbol();
// TypeError: Symbol is not a constructor
function* f() {};
const obj = new f;
// TypeError: f is not a constructor
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
Now you can create an object called mycar as follows:
const mycar = new Car('Eagle', 'Talon TSi', 1993);
For the latest version of web3, you have to set it up like:
xxxxxxxxxx
const { Web3 } = require('web3');
NOT:
xxxxxxxxxx
const Web3 = require('web3');
With the curly brackets around it.
xxxxxxxxxx
for "mongodb": "^4.1.0"
change
const ObjectID = require('mongodb').ObjectID;
to
const ObjectId = require('mongodb').ObjectId;
xxxxxxxxxx
//It's easy, just instanciate the class before
import {className} from './classPath'
myCLassInstance = new className(variables)
//then use it
myClassInstance.oneMethod()
//:)