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.
yep, that's a first!
i dont see how an ad blocker could possibly interfere with the variables, the code is evaluated server side, not client side
That is not true.
Array indices are based on some offset from the first address. A shift basically means setting a new first address.
Of course, this is assuming a standard implementation of the array data structure. If you implemented an array with a stack, then it will obviously be O(n) instead of O(1).
And if you really want to talk about worst case time complexities, a push could actually be an O(n) operation even for the standard implementation. It just depends on memory allocated.
ops[operation] || function() { return null; }
You need this function for other operation values beside "+-*/" and it would return null.
For example, if you get "m" or "w" as an operation, the compiler will give errors since m or w are not a method so OR function is needed to return null.
I might be wrong, but
(ops[operation] || function() {return null;})
seems to return a function fromops
object or a function that returnsnull
if no suchoperation
is defined. This is possible becauseops[operation]
returnsundefined
for unexistent members, which in turns forcesfunction () { return null; }
to be evaluated and returned.Basically, if the operation exists in the ops object I call its function with the num1 and num2 arguments.
If the operation does not exist in ops I default (using ||) to a function which returns null. num1 and num2 are also provided to the default function but are ignored.