Created
July 21, 2017 12:45
-
-
Save uniquename/2c08adf76de2b51472cb70449e8a556d to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Objects can have propperties and methods. | |
* | |
* Think of it as an abstraction of real world objects. | |
* | |
* There is much more to cover about objects!-) | |
*/ | |
var person = { | |
age: 32, | |
gender: 'm', | |
name: 'John', | |
lastname: 'Doe', | |
createSalutation: function() { | |
var salutation; | |
if (this.gender == 'f') { | |
salutation = 'Dear Mrs. '; | |
} else { | |
salutation = 'Dear Mr. '; | |
} | |
salutation += this.name + ' ' + this.lastname; | |
return salutation; | |
} | |
} | |
// how to call a method | |
var mySalutation = person.createSalutation(); | |
//console.log(someVariable); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment