edit: js, crockford style