diff options
Diffstat (limited to 'javascript.html.markdown')
-rw-r--r-- | javascript.html.markdown | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown index 1dd6e2be..6b6be34d 100644 --- a/javascript.html.markdown +++ b/javascript.html.markdown @@ -1,7 +1,8 @@ --- language: javascript -author: Adam Brenecki -author_url: http://adam.brenecki.id.au +contributors: + - ["Adam Brenecki", "http://adam.brenecki.id.au"] +filename: javascript.js --- Javascript was created by Netscape's Brendan Eich in 1995. It was originally @@ -218,6 +219,8 @@ function myFunction(){ // this code will be called in 5 seconds' time } setTimeout(myFunction, 5000); +// Note: setTimeout isn't part of the JS language, but is provided by browsers +// and Node.js. // Function objects don't even have to be declared with a name - you can write // an anonymous function definition directly into the arguments of another. @@ -354,13 +357,16 @@ myObj.meaningOfLife; // = 43 // Constructors have a property called prototype. This is *not* the prototype of // the constructor function itself; instead, it's the prototype that new objects // are given when they're created with that constructor and the new keyword. -myConstructor.prototype = { +MyConstructor.prototype = { + myNumber: 5, getMyNumber: function(){ - return this.myNumber + return this.myNumber; } }; -var myNewObj2 = new myConstructor(); +var myNewObj2 = new MyConstructor(); myNewObj2.getMyNumber(); // = 5 +myNewObj2.myNumber = 6 +myNewObj2.getMyNumber(); // = 6 // Built-in types like strings and numbers also have constructors that create // equivalent wrapper objects. |