Subj : Re: How do you make an object's property const? To : netscape.public.mozilla.jseng From : Wired Earp Date : Tue May 25 2004 04:40 pm celsoaguiar@hotmail.com (Celso Aguiar) wrote in news:803478e8.0405101626.3e11855@posting.google.com: > I've been trying to figure out how to make an object's > property constant from JavaScript, and have not found a > way, at least within SpiderMonkey latest 1.5. > > const O = function () { > this.p = 1; // can't do "const this.p = 1", syntax error. > } > const o = new O(); > o.p = 2; // I still can replace o.p This throws a "Typeerror: setting a proptery thas has only a getter", much to the same effect. const O = function () { const x = 0; this.p getter = function () { return x; } }; const o = new O(); o.p = 2; // no can't do -- Wired Earp Wunderbyte .