How to make a calculation when instantiating an object?

Asked

Viewed 25 times

0

Hello, I would like to know how do for a property of an object receive a value from one against among other properties, for example

objeto = {
 valor1: 10,
 valor2: 2,
 valor3: valor1 * valor2 ????
}

I am trying to do this in typescript, but I get an error saying:

'cannot find name valor1'.

Thanks

  • There is no way to do it this way because the value is not set yet.

  • Ahhhh blz, I’ll try to use another logic then, thank you

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.