1

I'm trying to execute the following code in my script:

var current = x.getObj(0);
current.delete();

I realized that delete is a keyword and is being treated as an operator instead of a function so I'm getting a "missing name after . operator" error. How can I explicitly run it as a function?

4
  • 1
    what is x? what is getObj ? Commented Mar 12, 2016 at 7:55
  • 1
    @RajaprabhuAravindasamy That's irrelevant to my question. I'm just using that line as an example. I care about the second line which is where I'm calling the delete function. Commented Mar 12, 2016 at 7:56
  • If I write var a = { delete: function() { console.log("hi") } } in console and then use a.delete(), it works for me. Commented Mar 12, 2016 at 8:00
  • 1
    Possible duplicate of javascript : why missing name after . operator alert appear Commented Mar 12, 2016 at 8:01

1 Answer 1

4

You can try something like: current["delete"]()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.