4

I was just wondering if the DELETE statement is supported by all browsers e.g:

delete myObj;

I just want to make 100% sure if all browsers support this or not? Also is there any browser or maybe mobile (cell) phones that do not?

Sam
  • 7,252
  • 16
  • 46
  • 65
Val
  • 17,336
  • 23
  • 95
  • 144
  • 3
    Not all browsers support Javascript, so no. – Mark Byers Jan 09 '10 at 21:00
  • 1
    `delete` is used to remove properties from objects (ie `delete foo.bar`, `delete foo[42]`, ...); strict-mode ES5 will even throw an `SyntaxError` if you incorrectly use it on local variables... – Christoph Jan 09 '10 at 21:30
  • 2
    @MarkByers Not all computers have mice. That doesn't mean I shouldn't write GUI's. I think it time for use to accept that the 'scriptless' web is deprecated, and not worth our design consideration any more the IE7 or the Netscape browser are. – gbtimmon Feb 28 '13 at 18:43

2 Answers2

9

Mozilla's Developer Center provides the following information:

Implemented in: JavaScript 1.2, NES3.0
ECMA Version:   ECMA-262

So you can check your target browser against this for an idea of whether it's supported at all or not.

Extreme testing of JavaScript delete operator on different browsers seems to suggest that nearly all major browsers do support it, just not equally well. Furthermore, the author provides an extreme test page for you to experiment with your browser online at http://www.trilancer.com/extreme_delete.html

I would also consider reading the following question for more details on how to property use the delete operator:

Community
  • 1
  • 1
Sampson
  • 265,109
  • 74
  • 539
  • 565
  • Although this is slightly off topic... it seems that it just tests the browsers speed or performance... however it does explain a lot about the delete so thanks – Val Jan 09 '10 at 21:17
  • @Val, I've since updated this solution to explain when it was introduced, how to use it, and how well it works in various browsers. – Sampson Jan 09 '10 at 21:18
  • @Jonathan I have noticed... thank you btw you have given more information than i would of thought i was going to get :) – Val Jan 09 '10 at 21:33
  • Unfortunately `http://www.trilancer.com/extreme_delete.html` is now a dead link `)-:` Looking for it in other locations ... – hippietrail Aug 10 '12 at 06:24
  • @JonathanSampson is the word `property` a typo? (near the end of last line). – Val Apr 16 '14 at 10:50
5

To directly answer your question, as far as I am aware, any browser that supports JavaScript supports delete. I checked and it existed in the specification for ECMAScript 1 (released in 1997) so it's been around for a while now.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rob Van Dam
  • 7,812
  • 3
  • 31
  • 34