0
Where is the variable of x and y?!
What is the output of this code? class Point { constructor(x,y) { this.x = X; this.y = y; } static slopeAB (A, B) { const dx = A.x-B.x; const dy = A.y-B.y; return dy/dx; } } const P1 = new Point(1,2); const P2 = new Point(3,4); console.log(Point.slopeAB(P1, P2));
1 Respuesta
+ 1
Nika Golestani
Variable of x and y? x and y are already a variable of constructor of class Point.
Here slopeAB is a static method which has two objects A and B which are P1 and P2.