Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var com = window.com || {};
- com.mynamespace = com.mynamespace || {};
- com.mynamespace.newpackage = (function() {
- var myPrivateVariable = "hidden";
- var myPublicVariable = "exposed";
- function myPrivateMethod() {
- return "also hidden";
- }
- function myPublicMethod() {
- return "also exposed";
- }
- return {
- myPublicMethod: myPublicMethod,
- myPublicVariable: myPublicVariable
- };
- })();
- # create a factory for MyObject
- my_factory = MyObject
- instance_1 = my_factory.new
- # change the factory to another class
- my_factory = MyOtherObject
- instance_2 = my_factory.new
- var singleton = {
- sayHello: function() {
- alert("Hello!")
- }
- };
- // This object controls the progress of the animation
- ex1 = new Animator();
- // The Animator's subjects define its behaviour
- ex1.addSubject(updateButton);
- function updateButton(value) {
- $('ex1Button').innerHTML = "Progress: " + Math.round(value * 100) + "%";
- }
- // now click below: each click to the button calls ex1.toggle()
Add Comment
Please, Sign In to add comment