Skip to content

Instantly share code, notes, and snippets.

@vishnu667
Created May 13, 2014 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishnu667/44063d64f2d1210c26c9 to your computer and use it in GitHub Desktop.
Save vishnu667/44063d64f2d1210c26c9 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
<script type="text/javascript">
var widgets = {
function1 : function(value){return value;},
function2 : function(value){return value+1;},
function3 : function(value){return value+2;}
};
function add_widget(name,widgetFunction){
widgets[name]=widgetFunction;
}
add_widget("widget4",function(value){return value+10;});
widgets["widget3"] =function(value){return value-1;};
for(var k in widgets ){
console.log(widgets[k](1));
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment