Created
April 19, 2019 08:01
-
-
Save tarhunakau/6686f7592a5cb15293bf045a3f9cd85f to your computer and use it in GitHub Desktop.
Hash function
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
// Добавьте в Object.prototype функцию hash, которая позволяет извлекать вложенные значения из объекта. | |
const obj = { | |
person: { | |
name: 'joe', | |
history: { | |
hometown: 'bratislava', | |
bio: { | |
funFact: 'I like fishing.', | |
}, | |
}, | |
}, | |
}; | |
obj.hash('car'); // undefined | |
obj.hash('person.history.bio'); // { funFact: 'I like fishing.' } | |
obj.hash('person.history.homeStreet'); // undefined | |
obj.hash('person.animal.pet.needNoseAntEater'); // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment