Answer the question
In order to leave comments, you need to log in
OOP its methods, parameters, how to figure it out?
There is a .length method , it is without brackets, there are methods where you just need to put brackets, for example
method() , there are methods where you need to set parameters method(1,2) .
Question: how to find out where to put brackets and where not, where to set method parameters, and where not.
Answer the question
In order to leave comments, you need to log in
First, length without parentheses is not a method, but a field. Secondly, you can find out where it is necessary to pass parameters, and where it is not necessary, in the documentation.
.length without brackets is not a method, but a property.
Go back to the beginning of the tutorial and carefully re-read about fields, methods, properties.
class Dog {
name = 'Тузик' // поле (свойство) .name используется без скобок
function getName() { // метод, getName() возвращающий имя, со скобками.
return this.name
}
function move(x,y) { // метод перемещающий тузика, у него не просто скобки, туда в скобки еще координаты подставить нужно
// ......
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question