Javascript FAB framework on Node.js -


i've seen slide presented fab, node.js framework.

fab slide

is javascript?

could explain going on in code?

i'm lost.

is plain javascript, function chaining pattern.

the first line, ( fab = require("fab") ) includes fab function , returns reference it.

all subsequent parentheses function calls, each function invocation returns same function again , again.

the pattern looks simplified example:

var foo = function (arg) {   // detect argument   if (typeof arg == 'function') {     // arg     console.log('function: '+arg());   } else if (arg instanceof regexp) {     // arg regexp...     console.log('a regexp: '+arg);   } else if (typeof arg == "string") {     // arg string     console.log('a string: '+arg);   }   return foo; // return reference };  (foo)   (function() { return "foo "; })   (/bar/)   (" baz!"); 

outputs:

 function: foo regexp: /bar/ string: baz! 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -