JavaScript tricks and some unexplainable behaviours