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.
This comment is hidden because it contains spoiler information about the solution
love this
I agree. Also, in Node.js there is URL constructor available where you can parse the host easily then in JS we also have location.host. So why reinvent the wheel.
great detaild explanation!
@pepkin88: It would be nice if we had benchmarks on different engines, because I'm hesistant to declare one solution or another "best practices" without seeing some performance measures...
[].concat
looks for propertyconcat
in the newly created object[]
. It doesn't find it, so it looks for that property in the prototype of that new array object.Array.prototype.concat
also makes 2 lookups, first forprototype
property of Array function, second forconcat
property ofArray.prototype
object. So the difference is creation an empty array object[]
.All of that is only in theory, because the real behavior depends on the engine‘s implementation. It could be optimized for such situations and could skip some steps (eg. would skip creating a new, later unused, array object, or would translate
Array.prototype
directly to that object, without a lookup).Thank you for the detailed explanation xcthulhu! Your response has helped to clear up some of my confussion with apply().
In the comments for this post on SO, SLaks explanation of
[]
versusArray.prototype
was:"
[]
is shorter, but it creates an extra array instance.Array.prototype
is longer but faster."I'm not sure if that's correct, so maybe somoene here can verify that is the case and provide a citation to documentation that indicates the veracity of the statement.
cool solution!!!!
you win, sir.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution