Examplet Center

Javascript Examplets and Examples

Select the following Topics you are interested

  1. List of all Javascript Examplets and Examples

Javascript Example - Javascript function closures and design of encapsulated javascript object and class

Javascript Example is extracted from article "Javascript function closures and design of encapsulated javascript object and class " from Cloudgen's Javascript Laboratory


Note for using this example:

There is no detailed explanation for this example.


Source code for the example:

<script type="text/javascript">
function closures(obj){
	var data;
	obj.getData=function(){return data}
	obj.setData=function(e){data=e}
}
a={};
closures(a);
a.setData("abc");
closures(a);
document.write("a="+a.getData()+"<"+"br/>");
</script>
Output:

Copyright 2010 Cloudgen Wong