1

I am trying to get the function in a function with argument inside the child function

function firstF (){
  this.childF1 = function($argument){
    // do something + $argument
  }
  this.childF2 = function($argument2){
    // do something + $argument2
  }
}

//Declare a new firstF
var firstFunction = new firstF();
firstFunction.childF1

how do i declare the $argument here?

2

1 Answer 1

2

You do it like this:

var firstFunction = new firstF();
firstFunction.childF1(arghere)

childF1 is a property of your firstF object and that property is a function. So, you call it like a function with parens and you pass the arguments in the parens. You must call it on an already created object of type firstF, not on the firstF function itself.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.