`delete` is a keyword in Javascript. You can't use it as an
identifier. Without knowing what you are doing in "..." I can't say
more.
Rhino 1.6 release 5 2006 11 18
js> var foo = {'delete': 42}
js> foo.delete
js: "<stdin>", line 3: missing name after . operator
js: foo.delete
js: .........^
js: "<stdin>", line 3: Compilation produced 1 syntax errors.
js> foo['delete']
42
js>
Accidentally, you _can_ say `foo.delete` to the OL debugger and get an
answer, because the debugger's simple evaluator does not know that
`delete` is a keyword.
[Also note, in general, you will not be able to enumerate the methods
of a class by looking at the properties of an instance. Yes, that's
the way it is implemented (for now) in DHTML, but your code will not
be portable to swf9, and I expect Javascript "Harmony" will have a
class-like feature that will also make your code non-portable.]
On 2009-09-23, at 10:49, Rami Ojares / AMG Oy wrote:
Hi,
Does anyone know why a method with name delete is ignored?
I have a class with a method named delete:
<class ...>
<method name="delete">
...
</method>
</class>
When I go through it's attributes using:
for (var name in instanceOfClass) ...
the object does not contain function with that name
But when I change the name to say delete1 then everything works as
expected.
Strange?
...
Thinking for a while before sending I came to the conclusion that it
must be because there exists a delete operator in javascript.
So delete can not be a variable name because it is a reserved word.
Compiler warning would be great in these kind of situations.
- rami