some useful js code