开发者

Yet another JS newbie question

开发者 https://www.devze.com 2023-02-15 21:25 出处:网络
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 wri

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";
0

精彩评论

暂无评论...
验证码 换一张
取 消