Created
October 20, 2018 11:07
-
-
Save oyilmaztekin/44f226c2c8b3cc0b2b0bec89cae355de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Person(firstname, lastname) { | |
| this.firstname = firstname || 'Default'; | |
| this.lastname = lastname || 'Default2'; | |
| this.getFullName = function(firstname, lastname) { | |
| return this.firstname + ' ' + this.lastname; | |
| } | |
| } | |
| var jane = new Person('jane'); | |
| var getFormalFullName = function() { | |
| return this.lastname + ', ' + this.firstname; | |
| } | |
| Person.prototype.getFormalFullName = getFormalFullName; | |
| Person.prototype.getFullNameProto = function() { | |
| return this.firstname + ' ' + this.lastname; | |
| } | |
| var john = { | |
| firstname: 'John', | |
| lastname: 'Doe' | |
| } | |
| console.log(jane.getFullName()); | |
| console.log(jane.getFormalFullName.call(john)); | |
| function Person2(firstname, lastname){ | |
| this.firstname = firstname | |
| this.lastname = lastname | |
| } | |
| // john.__proto__ = jane; | |
| // console.log(john.getFullName()) | |
| // var person2 = new Person2('prototype','cemil'); | |
| // Person2.prototype = Person.prototype |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment