some useful javascript code snippet