Select the following Topics you are interested
Javascript Example is extracted from article "Javascript function closures and design of encapsulated javascript object and class " from Cloudgen's Javascript Laboratory
There is no detailed explanation for this example.
<script type="text/javascript">
function closures(obj){
var data;
obj.getData=function(){return data}
obj.setData=function(e){data=e}
}
a={};
b={};
closures(a);
closures(b);
a.setData(234);
document.write("a="+a.getData()+"<"+"br/>");
b.setData("abc");
document.write("b="+b.getData()+"<"+"br/>");
</script>
Output: