Guest User

Untitled

a guest
Nov 19th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. var Test = new function() {
  2. this.init = new function() {
  3. alert("hello");
  4. }
  5. this.run = new function() {
  6. // call init here
  7. }
  8. }
  9.  
  10. var Test = new function() {
  11. this.init = function() {
  12. alert("hello");
  13. };
  14.  
  15. this.run = function() {
  16. // call init here
  17. this.init();
  18. };
  19. }
  20.  
  21. Test.init();
  22. Test.run();
  23.  
  24. // etc etc
  25.  
  26. function test() {
  27. var self = this;
  28. this.run = function() {
  29. console.log(self.message);
  30. console.log("Don't worry about init()... just do stuff");
  31. };
  32.  
  33. // Initialize the object here
  34. (function(){
  35. self.message = "Yay, initialized!"
  36. }());
  37. }
  38.  
  39. var t = new test();
  40. // Already initialized object, ready for your use.
  41. t.run()
  42.  
  43. var Test = function() {
  44. this.init = function() {
  45. alert("hello");
  46. }
  47. this.run = function() {
  48. // call init here
  49. this.init();
  50. }
  51. }
  52.  
  53. //creating a new instance of Test
  54. var jj= new Test();
  55. jj.run(); //will give an alert in your screen
  56.  
  57. var Test = function() {
  58. this.init = function() {
  59. alert("hello");
  60. }
  61. this.run = function() {
  62. this.init();
  63. }
  64. }
Add Comment
Please, Sign In to add comment