Prototype?

Andrii
Kilo Guru

Hi,

Trying to understand some basics of prototyping in ServiceNow and looking for answer - What does the following string mean?

WFActivityHandler.prototype.initialize.call(this);

1 ACCEPTED SOLUTION

derycklio
Mega Expert

Hi



Prototype is, in fact, a key feature of JavaScript - http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/



The call function refers to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call



In short, you can roughly read it as "Considering this as the current subject, treat it as WFActivityHandler and execute the initialize method with no parameter"



It is particularly useful if you need to handle inheritance with JavaScript, when you can't call a method of the super class with the super keyword like Java.


View solution in original post

4 REPLIES 4

derycklio
Mega Expert

Hi



Prototype is, in fact, a key feature of JavaScript - http://javascriptissexy.com/javascript-prototype-in-plain-detailed-language/



The call function refers to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call



In short, you can roughly read it as "Considering this as the current subject, treat it as WFActivityHandler and execute the initialize method with no parameter"



It is particularly useful if you need to handle inheritance with JavaScript, when you can't call a method of the super class with the super keyword like Java.


OK, then could you please explain what specifically it does in "Wait for Condition" activity?


coryseering
ServiceNow Employee
ServiceNow Employee

Hi Andrii,



Deryck gave you a couple of resources that you can use to learn about prototypical inheritence in JavaScript. It's not a small question to answer, but if you go through the links he gave you, you will learn how it works, and then can understand how it is used in the context of the Wait for Condition activity. Until you've familiarzed yourself with the concepts and their applications, trying to explain how it is used in this case would require covering all of that information first.



Since he already gave you some good links to the topics, you should look there first.


Hi Cory,



Yes, his answer if helpful, however i think I asked the wrong question - I'm not looking for basic that I know already - I'm looking for specific application of prototype thinking in specific example.



Anyway, I'm in progress