Created
June 13, 2012 02:23
-
-
Save NatashaTheRobot/2921433 to your computer and use it in GitHub Desktop.
Working with Javascript Hashes
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
<script> | |
var english = { | |
house: "A building for human habitation", | |
tree:"A woody perennial plant", | |
street: "A public road in a city or town" | |
}; | |
var americanEnglish = Object.create(english, { | |
elevator: "A platform or compartment housed in a shaft for raising and lowering people or things to different floors or levels", | |
truck: "A wheeled vehicle, in particular" | |
}) | |
var britishEnglish = Object.create(english); | |
britishEnglish.lift ="Raise to a higher position or level"; | |
britishEnglish.lorrie ="A large, heavy motor vehicle for transporting goods or troops"; | |
console.log(americanEnglish.elevator); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assignment: Prototypes
Make 3 "dictionary" style objects that map from words to their definitions.
Use Object.create() to make the prototype relationships. This function does not come with JavaScript, you will need to include a copy from http://javascript.crockford.com/prototypal.html
Do not use the keyword "new" for this exercise, except in the definition of Obect.create