English 中文(简体)
私营职能与公共职能之间的差别如何?
原标题:What is the difference between a private and public function?

我是一位新的方案家,我从C开始,现在开始享受Java的古典和更多的购买力平价。 最近,我听到了许多私人和公共职能。 是否有任何人解释方案执行者对两者及其如何使用?

在这里,我大概是完全错误的......,但这是一个错误。

(function(){}) 

a) 私人职能。

最佳回答

“公共”和“私人”这两个术语实际上与Javascript相对应。 关键是:你有办法提及你知道存在的某些职能? 也就是说,你能否以姓名(直接或作为你可以参考的另一物体的财产)提及? 如果是,祝贺,你可以称职。 否则,你就可以了。

这意味着,一项职能的“宣传”不是像 Java或C. 那样的静态事物。

var x = (function() {
  function maybePrivate() { return "my privates!"; }

  return {
    getMyPrivates: function() {
      var rv = maybePrivate;
      this.getMyPrivates = function() { return null; };
      return rv;
    }
  };
})();

Weird。 因此,现在,“x”是一个目标,你可以看到那里有“可能的私营”功能。 然而,这一名称——“可能繁荣”——并不好,因为从outside<>em> x 您可以不使用名称来履行职务。

然而,该物体有another功能,称为“getMyPrivates”,而can/em>。 当你打电话时,你回过头提到“可能的私营”职能,然后可以使用这一职能。 现在,“或许私营”仍然是私人的? 如果你这样做的话:

alert(x.getMyPrivates()());

页: 1 因此,它看起来像“可能繁荣”更是秘密。 然而,如果你尝试again,那么它就赢得了笔工作,因为“植被”安排自己在被首次传唤后被淘汰。

通过眼镜进行这种微小的行程是为了说明 Java具是动态的。 真正“静态”的唯一一点是,一旦你在封闭状态内(如上例的“可能私营”),你就可以迫使它从<<>外围<>上透露。 物体(至少不通过某种真正扭曲的争).;语言如此令人mus笑,以致于声称某些东西是“不可逾越的”:-)。 举例来说,该目标可以选择暴露其“私人”障碍,但也可以选择不。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.