postaja.js
class Postaja {
constructor (ime, x, y) {
this.ime = ime;
this.x = x;
this.y = y;
}
razdalja(destination) {
return 0.26591231 * Math.sqrt(Math.pow((this.x - destination.x), 2) + Math.pow((this.y - destination.y), 2));
}
}
module.exports = Postaja
povezava.js:
class Povezava {
constructor(zacetek, konec) {
this.A = zacetek;
this.B = konec;
}
razdalja () {
return 0.26591231 * Math.sqrt(Math.pow((this.A.x - this.B.x), 2) + Math.pow((this.A.y - this.B.y), 2));
}
}
module.exports = Povezava;
index.js:
import {default as povezava} from './components/povezava.js';
const pov = new povezava(Object.assign(postaja, tockaA), Object.assign(tockaB));
I encountered a problem when passing an object postaja
as a prameter to constructor of povezava
in index.js
. I have already checked that the value of postaja
objects is valid. Can anyone help me figure out what the problem is?