I'm looking to create a class so that it will return a value instead of the class object in ES6.
It's pretty much the same question as this but in ES6. This touches on it a little bit, but you still have to explicitly call a property.
I want to do something like:
class Foo {
constructor(value) {
this.value = value; // returns an object other than *this*.
}
}
var foo = new Foo(4);
console.log(foo) // 4
But currently it returns {value: 4}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With