Javascript flow control statement