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.
That’s a very interesting point, thanks. I want to clarify though, since you say "call" and "reevaluate", that this not calling a function but accessing a property of the (immutable) string.
How this is handled internally by the JS engine is a different question; there’s a more in-depth discussion that touches on this on StackOverflow. In short, caching
.length
has no effect on real-world performance in V8, Firefox, etc.(Note that in this case the entire issue can be avoided by using e.g.
str.slice(0, -1)
.)You call .length many times, and every time it has to be revaluated.
hahaa that's really clever xD