Hi everybody. Please help with such problem For example. We have function1 (param1, param2, param3)
{
Block working with Parameter 1
Block working with Parameter 2
If (Parameter 3 === 1) {function2()}
If (Parameter 3 === 2) {function3()} }
My question. Is it possible send function (or function name or something) as parameter Something Like this: function1 (param1, param2, param3)
{
Block working with Parameter 1
Block working with Parameter 2
param3_funct
}
Call from Program Body
function1(eact_param1_1, exact_param2_1, function2)
or
function1(eact_param1_2, exact_param2_2, function3)
When I tried to do this I received error
finction2 and function3 started immediately after call before function1 started, beforу Block working with Parameter 1 and 2 OK. I repeat my question Is It Possible Such Call function as parameter or not Thank You in advance Sincerely Mikhail
Thank You very much Now my code working. My mistake was here: functionaddStudent(id, refreshCallback){refreshCallback();} I forget about "()" after "parameter function name" Sincerely Misha
Sure, you can pass a function as the parameter of a function. This usage is very common for passing a callback function.
Doing an Internet search for "javascript pass function as parameter" turns up 38.200,000 results. I'm sure you can find what your looking for.
Should be pissible.....
Are you searching for something like this? (for example)
x + y * z = ????????? (23?)
Then 23-22 = ???? ---> ( 1 ? )
You need ASYNC-AWAIT
$w.onReady(async function () { let x = 3; let y = 4; let z = 5; let RESULT = await myStartFunction(x,y,z); console.log(RESULT) start_secondResultFunction(RESULT) }) function myStartFunction(x,y,z) { return (x+y*z) } function start_secondResultFunction(RESULT) { console.log(RESULT-22) }
Take a look onto your CONSOLE!