ECMAScript Globals

An experiment to see whether the global variables of ECMAScript are reassignable.

by Ray Toal

JavaScript

/*
 * Hackish little script to see which of ECMAScript globals are writable
 * and which are not.  This script needs to be run in an environment
 * where the global object is referred to as 'window'.  Only a few
 * selected known global properties are tested.
 */

var properties = ("Infinity NaN undefined JSON Math eval isFinite isNaN" +
    " parseInt parseFloat decodeURI decodeURIComponent encodeURI" +
    " encodeURIComponent Array Boolean Number String Object Date" +
    " Function RegExp Error").split(" ");

var show = function (s) {
    document.write(s + "<br>");
};

properties.forEach(function (p) {
    show(p + "  " + Object.getOwnPropertyDescriptor(window, p).writable);
});