I have just started learning javascript and nodejs by following a tutorial. One of the code they used is:
var express=require('express');
var app=express();
app.listen(3000);
Now when I do:
console.log(typeof app);
console.log(typeof app.listen);
I get:
function
function
as the output. Now if the typeof app is function, then how can we use . operator with it to access some other function(listen)? I tried to read the express module but couldn't understand much.
Can anyone give a simple example where we use a function name with . operator to access some other function inside it?
I tried this:
var t=function(){
t.bar=function(){
console.log('bar');
}
};
t.bar();
But doesn't work.
t.barin your example until you've calledt()...function a() {} a.some = function() { console.log('Some'); }objects?