> On 21.7.2015, at 17:19, Domenic Denicola <[email protected]> wrote: > > From: Samuel Hapák [mailto:[email protected]] > >> Could you please explain it on example? >> >> Let’s say I have >> >> ``` >> let book = Map{author: {name: “John”, surname: “Doe”}, birthdate: >> “10-10-1990”}; >> ``` >> >> How would you extract `birthdate`? How would you extract `name`? > > Your syntax here is invalid in at least four different ways. > If this is still confusing, you may wish to turn to StackOverflow for > clarification, instead of es-discuss. I apologize for the syntax mistakes I made. I totally understand you receive tons of proposals from people who don’t bother to learn JavaScript. I understand that this pissed you off and I am sorry for that. My bad.
Here is the valid syntax: ```js let book = new Map([['author', Map([['name', 'John'], ['surname', 'Doe']]), ['birthdate', '10-10-1990']]); let book2 = new Map([['birthdate', '10-10-1990'], ['author', Map([['name', 'John'], ['surname', 'Doe']])]]); ``` Now, I wish to extract `birthdate` and `name`. I can't rely on the order of elements, because the code should accept any `book` that has same shape. Let's say, ordering of the items in the map is not the part of the contract. So, to clarify this, I want to write function that accepts `book` or `book2` and inside, it extracts `birthdate` and `name`. The code should work with both `book` and `book2`. I feel, that your solution is unable to achieve this, but I can be mistaken. Thanks! Samuel
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

