- 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.😅

23rd Jan 2022, 6:50 AM
Amber Singh Rathour Pandey
Amber Singh Rathour Pandey - avatar
1 Resposta
0
Will u send the code
23rd Jan 2022, 6:55 AM
Pariket Thakur
Pariket Thakur - avatar