var lucia = lucia || {};
Then you can do
lucia.name = 'New York';
lucia.say = function(){
alert('Okey');
}More details:
<script>
var lucia = function(){
return {
methodA: function(){
alert('Method A');
},
methodB: function(){
alert('Method B');
}
}
};
var a = new lucia();
a.methodB()
a.methodA()
</script>
For private member:
<script>
var lucia = function(){
var name = 'Lucia Namespace';
function say(){
return name;
}return {
methodA: function(){
alert('Method A');
},
methodB: function(){
alert('Method B');
}
}
};
var a = new lucia();
a.methodB()
a.methodA()
</script>
No comments:
Post a Comment