I am learning JavaScript and I found this example
say("Hello")("World");
This code should return "Hello World".
I donβt know how to implement this even what type of keyword for google to search for souls. Can you please advise me what is the name of this template or how can it be implemented in JavaScript?
You can do:
function say(firstword){ return function(secondword){ return firstword + " " + secondword; } }
http://jsfiddle.net/o5o0f511/
You would never do this in practice. I am sure it is just to teach you how functions can return executable functions.
Here are some more examples of this template:
How do JavaScript closures work?
Perhaps you can try closing:
var say = function(a) {//<-- a, "Hello" return function(b) {//<-- b, "World" return a + " " + b; }; }; alert(say("Hello")("World")); //<-- "Hello World"
, say("Hello"), . ("World") , "Hello World"
say("Hello")
("World")
Source: https://habr.com/ru/post/1657543/More articles:Less-Loader: Import URLs are treated as relative URLs, without passing the -relative-url option - lessHow to properly configure KBuild Makefiles to create subfolders inside a kernel module - cGit: a function branch appears in the main branch when I do not merge them - gitMATLAB: provide feature sharing - matlabExecuting a method inside a method - javascriptWPF: hiding an object causes a brief flash before disappearing - data-bindingReactJS + Redux: how do I wait for the submission to complete before proceeding to the next step? - javascriptHow to remove external resource from jsfiddle? - javascriptCheck if Elixir module exports a specific function - elixirIs it safe to use zero as a second index when accessing Eigen :: VectorXd? - c ++All Articles