0

I have following methods:

function do(name){}


function name(text){    
      alert(text);
}

what if I want to make something like:

do(name('123456789')) {}

Is that possible and how I manage to do that?

2
  • 1
    As in Pass a JavaScript function as parameter ? Commented Apr 10, 2017 at 11:22
  • Can you at-least write correct pseudo code do(name('123456789')) {} Commented Apr 10, 2017 at 11:22

2 Answers 2

3

Do is a Reserved word, try this:

function make(nameFunction,argFunction){
  nameFunction(argFunction);
}

make(name,"works");

function name(text){    
      console.log(text);
}
Sign up to request clarification or add additional context in comments.

Comments

2

You just return value from function that you are going to pass as parameter to other function and now value of parameter in that function is returned value from other function that you passed.

function x(param){
  return param + 1;
}

function y(param){    
  return param + 1;
}

console.log(y(x(1)))

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.