- 4
A Class with object parameters
Hi, SoloLearn, I’m trying to create a constructor in a class, so it accepts an object, so I can do this: Var x = new TargetingClass({ x :2, y:3, z:4}); //What should I do so it can work like this? Console.log(m.target()); //It’s a method which prints the (x, y, z). I did this: constructor(n) { n = { blah:blah, blah1:blah2, ...} //You get the point. But it’ll show an error, that name is already assigned, something like that. I don’t know. So, I tried this.n, Now it shows the pairs but doesn’t update.😅
1 Odpowiedź
0
Will u send the code