I'm a little new to JavaScript, so bear with me if this is a dumb question.
Let's say that I have a class that looks like this:
var obj = function () { var val; return { setVal: function(newVal) { val = newVal; }, getVal: function() { return val; } }; };
Assuming my syntax is correct, it defines a class with the property "private" with the name "value" with methods for setting / getting the property. Now I will create two objects from this class:
var myObj = obj(); var yourObj = obj();
Does it create a separate setVal () and getVal () method for each object? If not, why not? If so, is this a serious concern when building effective web applications? Is a compromise (if any) effective for closing it in most / all contexts? I'm dumb?
Thanks Gerard
performance javascript closures oop
Grardb
source share