Reputation: 2720
Been bothering me for a while - I can't find the JS libraries to look at the code behind functions.
Reason I need it is for educational purposes so explain setters and getters with an example.
Where can I find such information?
Upvotes: 0
Views: 126
Reputation: 14269
You can always have a look at the Mozilla Developer Network sheets, for the properties of the object, not the source code: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date
If you want the implementation in JavaScript, you can download a sample reference source code from ecmascript web site: http://www.ecmascript.org/download.php
Upvotes: 0
Reputation: 387707
Date is not a JS library, but a core object/type of JavaScript. If you are really interested in its code, you should look for the source of some browser, although I'm not sure if you'll really see real JavaScript code for that (it might be written in native code).
Instead you should rather look at some real JS libraries or just make up an example yourself.
Upvotes: 2
Reputation: 1038850
The implementation of this object is browser dependent. Usually it will look at the system time.
Upvotes: 0
Reputation: 630429
There is no JavaScript code behind Date()
, it's a native object, implemented by the browser, usually in C for example.
You can view what it implements by taking a look at the spec (Section 15.9), but the exact code to do this is per-browser...if you wanted to see that you'd need to grab the source to Chrome or Firefox for example, but it's going to vary by browser.
Upvotes: 2