eclipse - Javascript : Syntax error on token "delete", StringLiteral? -
var testfunction = function () { return { delete: function() { // line 1 // } }; }
getting below error on line 1 in eclipse
syntax error on token "delete", stringliteral
as changed "delete" "delete1" , error goes away . delete reserved keyword ?
yes, delete
reserved keyword, used remove property in object, not iterable anymore. thus, given:
var = { b: 5 }; delete a.b; console.log(a); // logs {}
it can used remove "global variables" properties of global object too, is:
delete a; // in browsers equal delete window.a;
notice can use delete
property name too, need quote it:
var obj = { 'delete': function() { // line 1 // } }; obj['delete']();
Comments
Post a Comment