Web Analytics Made Easy -
StatCounter Can JavaScript code be more object-oriented? - CodingForum

Announcement

Collapse
No announcement yet.

Can JavaScript code be more object-oriented?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can JavaScript code be more object-oriented?

    Hi, have you ever see such example?
    Code:
    dsc.Class["com.example.HelloWorld"] = {
      Extends: "descript.events.EventDispatcher",
      Import: "descript.ui.PopupWindow",
      
      popup: null,
      
      HelloWorld: function(){
        //initialize itself
        this.popup = new descript.ui.PopupWindow("example", 300);
        this.popup.setContent("Hello World! This is an example from descript.org.");
      },
      
      sayHello: function(){
        //show message
        this.popup.show();
        //broadcast event
        this.dispatchEvent(new descript.events.Event("hello"));
      }
    };
    If not check the full Hello world! example - tell me what you thing about it.
    Descript.org - lightweight JavaScript foundation framework
Working...
X