简体   繁体   English

NetBeans是否可以识别JavaScript原型继承?

[英]Does NetBeans recognize JavaScript prototypal inheritance?

Does NetBeans recognize JavaScript prototypal inheritance? NetBeans是否可以识别JavaScript原型继承? To me it seems that it does not: 在我看来,它并没有:

Code: 码:

function A() {} 
A.prototype.doSomething = function () {} 

function B() {} 
B.prototype = new A(); 

var test = new B(); 
test.

after typing the dot and pressing ctrl+space I do not see doSomething()-method, but everything in B is covered though (in this example nothing). 键入点并按ctrl + space后,我看不到doSomething()方法,但是B中的所有内容都被覆盖了(在本例中为空)。

Netbeans, being a Java IDE, does, indeed, not function fully with JS, 实际上,作为Java IDE的Netbeans不能完全与JS一起使用,

prototype inheritance being one of these things. 原型继承就是这些事情之一。

In fairness - I can't see this being a common or critical issue. 公平地说-我看不出这是一个常见或关键的问题。

Yes it does (at least 7.0 beta2)! 是的(至少7.0 beta2)! You have to use prototype.js syntax for extending classes, but you can hide it in if (false) conditional, so you don't need the prototype.js actually... 您必须使用prototype.js语法来扩展类,但是您可以将其隐藏在if(false)有条件的情况下,因此实际上并不需要prototype.js ...

Your example will look like: 您的示例如下所示:

function A() {} 
A.prototype.doSomething = function () {} 

function B() {} 
B.prototype = new A(); 
// here is the magic trick
if (false) var B = Class.create(A, {});

var test = new B(); 

You can use any of these: 您可以使用以下任何一种:

  • var B = Class.create(A, {})
  • var B = Object.extend(new A(), {});

As a side note, the whole DOM is built around class-like inheritance, so it's rather important for IDEs to properly support it! 附带说明一下,整个DOM都是围绕类的继承构建的,因此IDE正确地支持它非常重要!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM