So I'm working on some code right now and there is this code I'm trying to understand. I've read a bit about it and it seems that the code is using object literals. So here is the code.
var car = function(){
// ...
function drive(model, color){
// ... do something
}
// ...
return {
start: drive
}
}();
Called in another file elsewhere
car.start(audi, black);
So how does this work. First it seems that in javascript a class can have a return method and not just a method. Also the return method is calling a method? using object literals? I'm a bit confused here.