Being a beginner in the world of JavaScript, I recently came across this code snippet in a tutorial. However, I am confused about the usage of functionName: function in the return statement.
Specifically, why do we have getID:function() and setID: function() in the following code? Could someone provide an explanation?
function celebrityID () {
var celebrityID = 999;
return {
getID: function () {
return celebrityID;
},
setID: function (theNewID) {
celebrityID = theNewID;
}
}
}