When you assign to another empty object, it is not “cleaning” the original object. You are just simply removing the reference to original object, create additional empty object and assign the original variable (in this case is
t ) to point to new empty object instead.
Thanks for your comment. Regarding the line you asked, it means:
Array is indexed collection, keeping all data allocated in memory consecutively. In case of large queue, every change will require moving large chunk of memory to keep array accessible using indices.
I don’t understand your question very clearly. Why do you want to use Object.keys? Object.keys will return an array of own enumerable properties of that specific object, but in this case we don’t need to know the whole array of properties, unless you have a different intention here.
While it is very nice and clean to use single line statement, I don’t think it will provide better performance than the tradition way of reversing a string. Let’s see: