How to call a member function from inside another member function?

I’ve two member functions on a type and I need to call one from the other, I tried something like:

function memberFunc1() {
  // some logic

function memberFunc2() {
  var res = this.memberFunc1();

but calling memberFunc2 from console, I get this error:

"TypeError: Cannot find function memberFunc1 in object [object Obj:TheType]. (TheType_memberFunc2.js#1888)"

What’s the appropriate way then?

I have an example where it is called through TheType.memberFunc1() you might want to try that

The current instance of TheType have some state that I need in to be passed memberFunc1.

Your first example should work. In what context are you running this code? Console UI? Server-side?

The two functions should run in server context

  memberFunc1: member function(.....): ResultType js server

  memberFunc2: member function(.....): double js server

Perhaps replace server by all.

Actually it worked like above as @matt said, I think I just didn’t provision properly.