Generate safe JS code that can used to reference a object property