some useful piece of code in JS