0 notes September 19, 2011 <jyap>quick question. https://gist.github.com/1228170 --> in function(rs), success() is called. is that calling the variable in function test1(success)? is that a javascript design pattern? <joshkehn>jyap: What do you mean? <Wa>yes and yes jyap <joshkehn>Oh. Yes <jyap>in mean i see success() is called. i don't get how it works. <jyap>Wa: where can i read up more about this design pattern? does it have a name? <Wa>success is an identifier, it doesn't matter whether it was a variable name or function name. You can set a function reference to a variable and call the variable etc <aho>it's just a callback <Wa>in such a case, success s- yeah that ^ <jyap>you can call back to the same function? is that what it's doing? <Wa>test1(function(){console.log("complete")}); it'll execute that function <aho>it's a different function (success), which is used to "call back" from within test1 <Wa>well that was an example but I guess they have that inline <Wa>test1(function() { util.log("SUCCESS"); process.exit(0); }) see that part <Wa>that function they made is passed as the success argument <jyap>test1(function() { util.log("SUCCESS"); process.exit(0); }) --> that's an inline function? <Wa>well it's called an anonymous function <tbranyen>or just a function expression <tbranyen>test1(function namedFunctionExpression() { }) <Wa>but yes, it's just creating that function and passing it as the first argument (ie. success) <tbranyen>yes <jyap>oh, i see, it's passing in that function as the argument <jyap>i'm less confused now. thanks all. Filed under JavaScript