Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Ah thank you! I see my mistake now =D
If the actual object field was called
name
you could use eitherobj['name']
orobj.name
. However,name
is a variable that represents some other value in this case.Can someone please explain why
obj[name]
works here, butobj.name
does not?I thought an object could use either syntax.
This comment is hidden because it contains spoiler information about the solution
Agree, though it is still slower in Firefox and IE11.
I am sure it will be someday the fastest solution.
I just tested it in Chrome 40, and map is now slightly faster than using a for loop.
This comment is hidden because it contains spoiler information about the solution
What objs.map is doing is for each object in the array it is handing it off to the function enclosed within the () that follow map.
That function is taking the objects map gives it (and map is giving it each object) therefore it will return obj[name] back to the map function and map creates a new array with that obj[name] pushed to it.
It is basically the shorthand for creating a new array and a for-loop that pushes to it.
Read more here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Who can explain the obj.map() to me?