When working with PHP, it is common practice to declare variables inside if statement parenthesis like so:
if ($myvar = myfunction()) {
// perform actions using $myvar
}
Is there an equivalent approach in JavaScript or TypeScript?:
if (const myvar = myfunction()) {
// perform actions using myvar
}