better javascript undefined check