B
B
Banan442020-04-30 12:07:48
JavaScript
Banan44, 2020-04-30 12:07:48

How to declare a class property outside the constructor?

class Auto {
  apple = 'Яблоко'
}

let car = new Auto
// car.apple = 'Яблоко' не нужно
console.log(car.apple)


Is it possible to do so? whether it is necessary to declare inside the constructor. And how to create static properties?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2020-04-30
@Banan44

1. You can
2. Static methods and Static fields

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question