I just want to have a function VK.Share.Count(param1,param2)
and property VK.Share.WorkUrl
.
VK.Share.WorkUrl
must be available from VK.Share.Count
function. What is best way to do it? Can i just write:
VK.Share.Count = function(a,b) {
//blablablablablalbalblablal
VK.Sha开发者_StackOverflow社区re.WorkUrl = "sdfgfgadf";
}
VK.Share.WorkUrl = "lalalala";
var vk={
share:{
count:function(){},
WorkUrl:"lalala"
}
};
or
var vk={}
vk.share={};
vk.share.count=function(){
}
vk.share.WorkUrl="lalal";
You example will work and this will also work, if you are always calling the Count function like this VK.Share.Count();
VK.Share.Count = function(a,b) { this.WorkUrl = "foobar"; }
VK.Share.WorkUrl = "123";
精彩评论