Answer the question
In order to leave comments, you need to log in
How to return a value from one method and get it in another?
Hey!
I just realized the truth that by setting variables globally I waste memory. Therefore, I am looking for a way without setting a variable globally to get its value in any of the methods.
Thus:
How can I get the value from a method checkMinMax()
in a method iterator()
without setting variables globally?
Code on codepan
Thank you all!
Answer the question
In order to leave comments, you need to log in
class foo {
method1() {
return 'hello' // return вы и сами написали
}
method2() {
let x = this.method1() // а вот результат никуда не присвоили
console.log(x)
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question