Javascript FAB framework on Node.js -
i've seen slide presented fab, node.js framework.
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
Post a Comment