Deprecated and obsolete features

This page lists features of JavaScript that are deprecated (that is, still available but planned for removal) and obsolete (that is, no longer usable).

Deprecated features

These deprecated features can still be used, but should be used with caution because they are not required to be implemented by every JavaScript engine. You should work to remove their use from your code.

Some of these deprecated features are listed in the Annex B section of the ECMAScript specification. This section is described as normative optional — that is, web browser hosts must implement these features, while non-web hosts may not. These features are likely stable because removing them will cause backward compatibility issues and break legacy websites. (JavaScript has the design goal of "don't break the web".) Still, they are not cross-platform portable and may not be supported by all analysis tools, so you are advised to not use them, as the introduction of Annex B states:

… All of the language features and behaviors specified in this annex have one or more undesirable characteristics and in the absence of legacy usage would be removed from this specification. …

… Programmers should not use or assume the existence of these features and behaviors when writing new ECMAScript code. …

Some others, albeit in the main spec body, are also marked as normative optional and should not be depended on.

HTML comments

JavaScript source, if parsed as scripts, allows HTML-like comments, as if the script is part of a <script> tag.

The following is valid JavaScript when running in a web browser (or Node.js, which uses the V8 engine powering Chrome):

<!-- comment
console.log("a"); <!-- another comment
--> More comment
// Logs "a" and "b"

<!-- and --> both act like //, i.e. starting line comments. --> is only valid at the start of a line (to avoid ambiguity with a postfix decrement followed by a greater than operator), while <!-- can occur anywhere in the line.


The following properties are deprecated. This does not affect their use in replacement strings:


Parenthesized substring matches, if any.

input, $_

The string against which a regular expression is matched.

lastMatch, $&

The last matched substring.

lastParen, $+

The last parenthesized substring match, if any.

leftContext, $`

The substring preceding the most recent match.

rightContext, $'

The substring following the most recent match.

Warning: Avoid using these static properties, as they can cause issues when interacting with external code!

The compile() method is deprecated. Construct a new RegExp instance instead.


  • The caller property of functions and the arguments.callee property are deprecated and unavailable in strict mode.
  • Instead of accessing arguments as a property of a function, you should use the arguments object inside function closures.




Escape sequences


The with statement is deprecated and unavailable in strict mode.

Initializers in var declarations of loops headers are deprecated and produce syntax errors in strict mode. They are silently ignored in non-strict mode.

Obsolete features

These obsolete features have been entirely removed from JavaScript and can no longer be used as of the indicated version of JavaScript.


The following are now properties of RegExp instances, no longer of the RegExp constructor:

Property Description
global Whether or not to test the regular expression against all possible matches in a string, or only against the first.
ignoreCase Whether or not to ignore case while attempting a match in a string.
lastIndex The index at which to start the next match.
multiline (also via RegExp.$*) Whether or not to search in strings across multiple lines.
source The text of the pattern.

The valueOf() method is no longer specialized for RegExp. It uses Object.prototype.valueOf(), which returns itself.


  • Functions' arity property is obsolete. Use length instead.


Property Description Alternative
__count__ Returns the number of enumerable properties directly on a user-defined object. Object.keys()
__parent__ Points to an object's context. No direct replacement
__iterator__ Used with legacy iterators. Symbol.iterator and the new iteration protocols
__noSuchMethod__ A method called when a non-existent property is called as method. Proxy
Object.prototype.eval() Evaluates a string of JavaScript code in the context of the specified object. No direct replacement
Object.observe() Asynchronously observing the changes to an object. Proxy
Object.unobserve() Remove observers. Proxy
Object.getNotifier() Create a notifier object that allows to synthetically trigger a change observable with Object.observe(). No direct replacement Attach a handler callback to a property that gets called when the property is assigned. Proxy
Object.prototype.unwatch() Remove watch handlers on a property. Proxy



  • WeakMap.prototype.clear() was added in Firefox 20 and removed in Firefox 46. It is not possible to traverse all keys in a WeakMap.



  • Non-standard Array generic methods like Array.slice(myArr, 0, 12), Array.forEach(myArr, myFn), etc. have been introduced in Firefox 1.5 (JavaScript 1.6), deprecated in Firefox 68, and removed in Firefox 71. You can use methods on Array.prototype together with instead.
Property Description Alternative
Array.observe() Asynchronously observing changes to Arrays. Proxy
Array.unobserve() Remove observers. Proxy



  • Proxy.create and Proxy.createFunction are obsolete. Use the Proxy() constructor instead.
  • The following traps are obsolete:


  • ParallelArray is obsolete.


Acquiring source text

The toSource() methods of arrays, numbers, strings, etc. and the uneval() global function are obsolete. Use toString(), or write your own serialization method instead.

Legacy generator and iterator

Legacy generator function statements and legacy generator function expressions are removed. The legacy generator function syntax reuses the function keyword, which automatically becomes a generator function when there are one or more yield expressions in the body — this is now a syntax error. Use function* statements and function* expressions instead.

Array comprehensions and generator comprehensions are removed.

// Legacy array comprehensions
[for (x of iterable) x]
[for (x of iterable) if (condition) x]
[for (x of iterable) for (y of iterable) x + y]

// Legacy generator comprehensions
(for (x of iterable) x)
(for (x of iterable) if (condition) x)
(for (x of iterable) for (y of iterable) x + y)

Firefox, prior to version 26, implemented another iterator protocol that is similar to the standard Iterator protocol. An object is an legacy iterator when it implements a next() method, which produces a value on each call and throws a StopIteration object at the end of iteration. This legacy iterator protocol differs from the standard iterator protocol:

  • The value was returned directly as the return value of calls to next(), instead of the value property of the IteratorResult object.
  • Iteration termination was expressed by throwing a StopIteration object, instead of through the done property of the IteratorResult object.

This feature, along with the StopIteration global constructor, was removed in Firefox 58+. For future-facing usages, consider using for...of loops and the iterator protocol.

Sharp variables

Sharp variables are obsolete. To create circular structures, use temporary variables instead.