What does "return function() { ... }" do in JavaScript? -


Recently I have seen this piece of javascript code, but it is unable to understand what it is trying to do is.

  var f = function (A) {return function () {warning (a () ()); }; }; F (function () {return "hello world";}) ();  

Please tell what this is!

This function implements that f returns. The f function returns a warning call that displays the output of the function given by f as the parameter of

Edit: Change the location of some parts to make it easier on the eyes and you will see yourself:

  var f = function (a) {Var Output = A (); Var AlertColor = Function () {Alert (Output); }; Warning of return; }; Var hello world = function () {return "hello world"; } Var Results = F (Hello World); // f takes a function as argument function (); // result should be a function  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -