...

View Full Version : missing name after . operator delete keyword



BubikolRamios
11-13-2010, 09:22 AM
this.delete = function(obj)
{
..


Is that it ? I can't have delete ? Or can this be written in some other way, including delete ?

glenngv
11-13-2010, 09:26 AM
delete is a reserved word in JavaScript.

Old Pedant
11-13-2010, 11:58 PM
delete is a reserved word in JavaScript.

Which means, if you want, you can just rename it Delete or DELETE, since JS is case sensitive and won't see those as the same as delete.

rnd me
11-14-2010, 01:39 AM
use JSON rules, which allows any key name: you just need to avoid the literal, array works fine:


function C(){
this['delete']=true;
}


alert(JSON.stringify(new C))


tested ie9,ff3.6

glenngv
11-14-2010, 10:40 AM
use JSON rules, which allows any key name: you just need to avoid the literal, array works fine:


function C(){
this['delete']=true;
}


alert(JSON.stringify(new C))


tested ie9,ff3.6
It doesn't work in IE8. Actually delete using dot and square bracket notations works in FF and Chrome and probably some other browsers too but not IE8 and below.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum