I saw this code inside a web application and wanted to understand it better (so as to be able to create this sort of structures myself), but I am not sure what kind of JavaScript this is.
What I mean is, is the Class.create() syntax part of "out of the box" JavaScript or part of some library that is embedded in this web application?
I saw this code inside a web application and wanted to understand it better (so as to be able to create this sort of structures myself), but I am not sure what kind of JavaScript this is.
What I mean is, is the Class.create() syntax part of "out of the box" JavaScript or part of some library that is embedded in this web application?
Share Improve this question asked Mar 5, 2015 at 22:10 user4277027user4277027 2- 6 It's a part of PrototypeJS API. – raina77ow Commented Mar 5, 2015 at 22:11
- As far as I understand the web application is ServiceNow. You can find the source code here: "Script Includes -> PrototypeServer" – filler36 Commented Feb 21, 2022 at 14:17
3 Answers
Reset to default 5Class
(as in window.Class) is not part of the JavaScript standard. Thus any method on it, including Class.create
, is not part of standard JavaScript.
Open up a vanilla console and do: typeof Class
.
The result is "undefined".
There exists Prototype and other "Class" variations - see which library is loaded.
So Class in this example is utility that is defined in one of the referenced script libraries. It is basically an abstraction on top of the javascript Object
, which will allow you to use certain built-in functionality like if you inherit from it and define your "class" you will have a _super
method which allows you to call a base class method definition.
Object.create()
Here's a the very best tutorial i found on the net about oop on js
I hope you understand bits of german. So ive learned objective js.