Am I allowed to declare prototypes in an object literal?
var Obj = function(){
var private = "Oh hi there I'm a private variable";
return {
init : function(param){
this.param =
return this;
}
prototype.sayHi: function(){
console.log("HI");
}
}
}
Would I now be able to call “Obj.sayHi”? Or is there a way to do this if the example is not possible?
You can use a local function to create the object with a prototype:
Demo: http://jsfiddle.net/Guffa/pZQnU/