PHP implementation of JavaScript build in objects