JS: Avoid error with undefined properties in sandbox