top-down javascript