Say I have a class
class Something {
constructor(a, b) {
this.a = a;
this.b = b;
}
}
How can I instantiate an object so that I only assign a value to b
without assigning a value to a
?
e.g. something along the lines of:
let someObject = new Something(b : 10);
with the expected output:
log(someObject.a) // undefined
log(someObject.b) // 10
I want to avoid let someObject = new Something(undefined, 10);
if I can for code readability reasons.
I'm kinda new to js, and I'm not really sure if this is even possible, but any help or guidance would be greatly appreciated!