diff --git a/Basic_Concepts/Promise/README.md b/Basic_Concepts/Promise/README.md index 5c9616c..a3e5063 100644 --- a/Basic_Concepts/Promise/README.md +++ b/Basic_Concepts/Promise/README.md @@ -4,13 +4,7 @@ A Promise represents an operation that hasn't completed yet, but is expected in the future. -# Course Documentation - -(this for me to fill up with every element - -that you use in lessons. syntax - -explaination and links for more) +# Course Documentation ## HTML diff --git a/Basic_Concepts/Prototype/README.md b/Basic_Concepts/Prototype/README.md index 423b6b8..22d93ed 100644 --- a/Basic_Concepts/Prototype/README.md +++ b/Basic_Concepts/Prototype/README.md @@ -1,26 +1,73 @@ ![](http://i.imgur.com/BgUMUGU.png) -# Prototype - -This MD file serves as example/template. +# Prototype -It will be filled up soon. +According to [W3schools](http://www.w3schools.com/js/js_object_prototypes.asp): +Every JavaScript object has a prototype. The prototype is also an object. +All JavaScript objects inherit their properties and methods from their prototype. -(for Bucky to fill up) # Course Documentation + + +## Javascript prototypes + +According to [W3schools](http://www.w3schools.com/js/js_object_prototypes.asp): +**Every JavaScript object has a prototype. The prototype is also an object.** + + Person.prototype.getName = function () { + return this.firstName + " " + this.lastName; + }; + +All JavaScript objects inherit the properties and methods from their prototype. +Objects created using an object literal, or with new Object(), inherit from a prototype called Object.prototype. +Objects created with new Date() inherit the Date.prototype. +The Object.prototype is on the top of the prototype chain. +All JavaScript objects (Date, Array, RegExp, Function, ....) inherit from the Object.prototype. + + Person.prototype.getName = function () { + return this.firstName + " " + this.lastName; + }; + + var bucky = new Person('Bucky', 'Roberts'); + var emily = new Person('Emily', 'Jones'); + + console.log(bucky.getName()); + console.log(emily.getName()); + +## Objects + +In our example for objects we used the following code: + + + Person.prototype.getName = function () { + return this.firstName + " " + this.lastName; + }; + + var bucky = new Person('Bucky', 'Roberts'); + var emily = new Person('Emily', 'Jones'); + + + That is the typical syntax of javascripts object as well: + + var objectname = { + property1: "property1valueinstringformat", + property2: property2valueinarithmeticformat + }; + +We achieve to insert more values in one variable by turning it to an object and by use the "property" format to each of our value + -(this for me to fill up with every element + { property: valueofproperty }; -that you use in lessons. syntax + Curley brackets are defining the are of the properties, and also they defining that our variable is an object, and we separate our properties with the comma symbol. -explaination and links for more) + - Read more about [Object Oriented + Programming](https://en.wikipedia.org/wiki/Object-oriented_programming) + - in Wikipedia Read more about [Javascript + Objects](http://www.w3schools.com/js/js_objects.asp) in W3schools -## Element to explain -(for example console.log) -***Links*** - - Wikipedia - - Anotherlink,com \ No newline at end of file +> Written with [StackEdit](https://stackedit.io/).