U
U
unknown2017-12-01 11:21:14
JavaScript
unknown, 2017-12-01 11:21:14

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

1 answer(s)
S
Stalker_RED, 2017-12-01
_

class foo {
  method1() {
     return 'hello' // return вы и сами написали
  }
  method2() {
     let x = this.method1() // а вот результат никуда не присвоили
     console.log(x)
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question