Reputation: 779
Studying Module pattern in javascript and see below.. Question.. why do you need return inside of return? what purpose does that serve?
var ex = function(){
return {
get: function(name){
console.log("helloe " + name);
return {
hostname: 'node1 '
}
}
}
}
Upvotes: 0
Views: 24
Reputation: 1626
Here you are returning an object literal.
var ex = function(){
return {
Here you are declaring a function get
inside that object literal.
get: function(name){
Here, you are returning an object literal each time the get
function is called.
return {
hostname: 'node1 '
}
Upvotes: 2