[JS] only set env prototype if exists