If you want to call nc methods within the nc object scope, you can create it as a singleton:

var nc = new function() {
    // anthing in here is private access for you
    var privateVar = 'foo';

    return {

        // and anything in here is publicly available
            publicVar: 'bar',
            alert: function(obj) {
                alert(privateVar + ' ' + this.publicVar + ' - ' + obj.msg);
            }
    }
}();

...
nc.alert({ msg: 'alrightly then...' });
...

Casey


On 06/12/2010 07:53, Discussion of JavaScript wrote:
Hi all,

Please help me with this object I created for just calling a function.

var nc = nc || {};

nc = {
  alert: function(obj){
    alert(obj);
  }
};

So, when I call it will become like nc.alert({ id:0 });

I want to create a global function within my system. So, I made 'nc' object to make more sense and standard function to my system.

The question ,
1. should I apply the prototype to the object nc?
2. or.. this 'nc' object I created is sufficient enough to call a function within 'nc' object scope?

Thank you.

--
Best Regards,
Hudz


_______________________________________________
JSMentors mailing list
[email protected]
http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com
_______________________________________________
JSMentors mailing list
[email protected]
http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com

Reply via email to