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));

25th Dec 2021, 6:55 AM
Nika Golestani
Nika Golestani - avatar
1 Resposta
+ 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.
25th Dec 2021, 7:03 AM
A͢J
A͢J - avatar