javascript useful functions