Deprecated and obsolete features - JavaScript | MDN Skip to main content Skip to search MDN HTML HTML: Markup language HTML reference Elements Global attributes Attributes See all… HTML guides Responsive images HTML cheatsheet Date & time formats See all… Markup languages SVG MathML XML CSS CSS: Styling language CSS reference Properties Selectors At-rules Values See all… CSS guides Box model Animations Flexbox Colors See all… Layout cookbook Column layouts Centering an element Card component See all… JavaScriptJS JavaScript: Scripting language JS reference Standard built-in objects Expressions & operators Statements & declarations Functions See all… JS guides Control flow & error handing Loops and iteration Working with objects Using classes See all… Web APIs Web APIs: Programming interfaces Web API reference File system API Fetch API Geolocation API HTML DOM API Push API Service worker API See all… Web API guides Using the Web animation API Using the Fetch API Working with the History API Using the Web speech API Using web workers All All web technology Technologies Accessibility HTTP URI Web extensions WebAssembly WebDriver See all… Topics Media Performance Privacy Security Progressive web apps Learn Learn web development Frontend developer course Getting started modules Core modules MDN Curriculum Check out the video course from Scrimba, our partner Learn HTML Structuring content with HTML module Learn CSS CSS styling basics module CSS layout module Learn JavaScript Dynamic scripting with JavaScript module Tools Discover our tools Playground HTTP Observatory Border-image generator Border-radius generator Box-shadow generator Color format converter Color mixer Shape generator About Get to know MDN better About MDN Advertise with us Community MDN on GitHub Blog Toggle sidebar Web JavaScript Reference Deprecated and obsolete features Theme OS default Light Dark English (US) Remember language Learn more Deutsch English (US) Español Français 日本語 Português (do Brasil) Русский 中文 (简体) 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). In this article Deprecated features Obsolete features 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): js <!-- comment console.log("a"); <!-- another comment console.log("b"); --> 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. RegExp The following properties are deprecated. This does not affect their use in replacement strings: $1–$9 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 following regex syntaxes are deprecated and only available in Unicode-unaware mode. In Unicode-aware mode, they are all syntax errors: Lookahead assertions can have quantifiers. Backreferences that do not refer to an existing capturing group become legacy octal escapes. In character classes, character ranges where one boundary is a character class makes the - become a literal character. An escape sequence that's not recognized becomes an "identity escape". Escape sequences within character classes of the form \cX where X is a number or _ are decoded in the same way as those with ASCII letters: \c0 is the same as \cP when taken modulo 32. In addition, if the form \cX is encountered anywhere where X is not one of the recognized characters, then the backslash is treated as a literal character. The sequence \k within a regex that doesn't have any named capturing groups is treated as an identity escape. The syntax characters ], {, and } may appear literally without escaping if they cannot be interpreted as the end of a character class or quantifier delimiters. Function 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. Object The Object.prototype.__proto__ accessors are deprecated. Use Object.getPrototypeOf and Object.setPrototypeOf instead. This does not apply to the __proto__ literal key in object literals. The Object.prototype.__defineGetter__, Object.prototype.__defineSetter__, Object.prototype.__lookupGetter__, and Object.prototype.__lookupSetter__ methods are deprecated. Use Object.getOwnPropertyDescriptor and Object.defineProperty instead. String HTML wrapper methods like String.prototype.fontsize and String.prototype.big. String.prototype.substr probably won't be removed anytime soon, but it's defined in Annex B and hence normative optional. String.prototype.trimLeft and String.prototype.trimRight should be replaced with String.prototype.trimStart and String.prototype.trimEnd. Date The getYear() and setYear() methods are affected by the Year-2000-Problem and have been subsumed by getFullYear and setFullYear. The toGMTString() method is deprecated. Use toUTCString() instead. Escape sequences Octal escape sequences (\ followed by one, two, or three octal digits) are deprecated in string and regular expression literals. The escape() and unescape() functions are deprecated. Use encodeURI(), encodeURIComponent(), decodeURI(), or decodeURIComponent() to encode and decode escape sequences for special characters. Statements The with statement is deprecated and unavailable in strict mode. Initializers in var declarations of for...in loops headers are deprecated and produce syntax errors in strict mode. The initializer expression is evaluated and assigned to the variable, but the value would be immediately reassigned on the first iteration of the loop. Normally, the catch block of a try...catch statement cannot contain any variable declaration with the same name as the variables bound in the catch(). An extension grammar allows the catch block to contain a var declared variable with the same name as the catch-bound identifier, but only if the catch binding is a simple identifier, not a destructuring pattern. However, this variable's initialization and assignment would only act on the catch-bound identifier, instead of the upper scope variable, and the behavior could be confusing. js var a = 2; try { throw new Error(); } catch (a) { var a = 1; // This 1 is assigned to the caught `a`, not the outer `a`. } console.log(a); // 2 try { throw new Error(); // Note: identifier changed to `err` to avoid conflict with // the inner declaration of `a`. } catch (err) { var a = 1; // This 1 is assigned to the upper-scope `a`. } console.log(a); // 1 This is listed in Annex B of the spec and hence may not be implemented everywhere. Avoid any name conflicts between the catch-bound identifier and variables declared in the catch block. Obsolete features These obsolete features have been entirely removed from JavaScript and can no longer be used as of the indicated version of JavaScript. RegExp 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. Function Functions' arity property is obsolete. Use length instead. Object 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 Object.prototype.watch() 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 String Non-standard String generic methods like String.slice(myStr, 0, 12), String.replace(myStr, /\./g, "!"), etc. have been introduced in Firefox 1.5 (JavaScript 1.6), deprecated in Firefox 53, and removed in Firefox 68. You can use methods on String.prototype together with Function.call instead. String.prototype.quote is removed from Firefox 37. Non-standard flags parameter in String.prototype.search, String.prototype.match, and String.prototype.replace are obsolete. WeakMap WeakMap.prototype.clear() was added in Firefox 20 and removed in Firefox 46. It is not possible to traverse all keys in a WeakMap. Date Date.prototype.toLocaleFormat(), which used a format string in the same format expected by the strftime() function in C, is obsolete. Use toLocaleString() or Intl.DateTimeFormat instead. Array 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 Function.call instead. Property Description Alternative Array.observe() Asynchronously observing changes to Arrays. Proxy Array.unobserve() Remove observers. Proxy Number Number.toInteger() is obsolete. Use Math.floor, Math.round, or other methods instead. Proxy Proxy.create and Proxy.createFunction are obsolete. Use the Proxy() constructor instead. The following traps are obsolete: hasOwn (bug 980565, Firefox 33). getEnumerablePropertyKeys (bug 783829, Firefox 37) getOwnPropertyNames (bug 1007334, Firefox 33) keys (bug 1007334, Firefox 33) ParallelArray ParallelArray is obsolete. Statements for each...in is obsolete. Use for...of instead. let blocks and let expressions are obsolete. Expression closures (function () 1 as a shorthand of function () { return 1; }) are obsolete. Use regular functions or arrow functions instead. 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. js // 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 a 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. Help improve MDN Was this page helpful to you? Yes No Learn how to contribute This page was last modified on Oct 30, 2025 by MDN contributors. View this page on GitHub • Report a problem with this content Filter sidebar Clear filter input JavaScript Tutorials and guides JavaScript Guide Introduction Grammar and types Control flow and error handling Loops and iteration Functions Expressions and operators Numbers and strings Representing dates & times Regular expressions Indexed collections Keyed collections Working with objects Using classes Using promises JavaScript typed arrays Iterators and generators Resource management Internationalization JavaScript modules Intermediate Language overview JavaScript data structures Equality comparisons and sameness Enumerability and ownership of properties Closures Advanced Inheritance and the prototype chain Meta programming Memory Management References Built-in objects AggregateError Array ArrayBuffer AsyncDisposableStack AsyncFunction AsyncGenerator AsyncGeneratorFunction AsyncIterator Atomics BigInt BigInt64Array BigUint64Array Boolean DataView Date decodeURI() decodeURIComponent() DisposableStack encodeURI() encodeURIComponent() Error escape() eval() EvalError FinalizationRegistry Float16Array Float32Array Float64Array Function Generator GeneratorFunction globalThis Infinity Int8Array Int16Array Int32Array InternalError Intl isFinite() isNaN() Iterator JSON Map Math NaN Number Object parseFloat() parseInt() Promise Proxy RangeError ReferenceError Reflect RegExp Set SharedArrayBuffer String SuppressedError Symbol SyntaxError Temporal TypedArray TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array undefined unescape() URIError WeakMap WeakRef WeakSet Expressions & operators Addition (+) Addition assignment (+=) Assignment (=) async function expression async function* expression await Bitwise AND (&) Bitwise AND assignment (&=) Bitwise NOT (~) Bitwise OR (|) Bitwise OR assignment (|=) Bitwise XOR (^) Bitwise XOR assignment (^=) class expression Comma operator (,) Conditional (ternary) operator Decrement (--) delete Destructuring Division (/) Division assignment (/=) Equality (==) Exponentiation (**) Exponentiation assignment (**=) function expression function* expression Greater than (>) Greater than or equal (>=) Grouping operator ( ) import.meta import.meta.resolve() import() in Increment (++) Inequality (!=) instanceof Left shift (<<) Left shift assignment (<<=) Less than (<) Less than or equal (<=) Logical AND (&&) Logical AND assignment (&&=) Logical NOT (!) Logical OR (||) Logical OR assignment (||=) Multiplication (*) Multiplication assignment (*=) new new.target null Nullish coalescing assignment (??=) Nullish coalescing operator (??) Object initializer Operator precedence Optional chaining (?.) Property accessors Remainder (%) Remainder assignment (%=) Right shift (>>) Right shift assignment (>>=) Spread syntax (...) Strict equality (===) Strict inequality (!==) Subtraction (-) Subtraction assignment (-=) super this typeof Unary negation (-) Unary plus (+) Unsigned right shift (>>>) Unsigned right shift assignment (>>>=) void operator yield yield* Statements & declarations async function async function* await using Block statement break class const continue debugger do...while Empty statement export Expression statement for for await...of for...in for...of function function* if...else import Import attributes Labeled statement let return switch throw try...catch using var while with Functions Arrow function expressions Default parameters get Method definitions Rest parameters set The arguments object [Symbol.iterator]() callee length Classes constructor extends Private elements Public class fields static Static initialization blocks Regular expressions Backreference: \1, \2 Capturing group: (...) Character class escape: \d, \D, \w, \W, \s, \S Character class: [...], [^...] Character escape: \n, \u{...} Disjunction: | Input boundary assertion: ^, $ Literal character: a, b Lookahead assertion: (?=...), (?!...) Lookbehind assertion: (?<=...), (?<!...) Modifier: (?ims-ims:...) Named backreference: \k<name> Named capturing group: (?<name>...) Non-capturing group: (?:...) Quantifier: *, +, ?, {n}, {n,}, {n,m} Unicode character class escape: \p{...}, \P{...} Wildcard: . Word boundary assertion: \b, \B Errors AggregateError: No Promise in Promise.any was resolved Error: Permission denied to access property "x" InternalError: too much recursion RangeError: argument is not a valid code point RangeError: BigInt division by zero RangeError: BigInt negative exponent RangeError: form must be one of 'NFC', 'NFD', 'NFKC', or 'NFKD' RangeError: invalid array length RangeError: invalid date RangeError: precision is out of range RangeError: radix must be an integer RangeError: repeat count must be less than infinity RangeError: repeat count must be non-negative RangeError: x can't be converted to BigInt because it isn't an integer ReferenceError: "x" is not defined ReferenceError: assignment to undeclared variable "x" ReferenceError: can't access lexical declaration 'X' before initialization ReferenceError: must call super constructor before using 'this' in derived class constructor ReferenceError: super() called twice in derived class constructor SyntaxError: 'arguments'/'eval' can't be defined or assigned to in strict mode code SyntaxError: "0"-prefixed octal literals are deprecated SyntaxError: "use strict" not allowed in function with non-simple parameters SyntaxError: "x" is a reserved identifier SyntaxError: \ at end of pattern SyntaxError: a declaration in the head of a for-of loop can't have an initializer SyntaxError: applying the 'delete' operator to an unqualified name is deprecated SyntaxError: arguments is not valid in fields SyntaxError: await is only valid in async functions, async generators and modules SyntaxError: await/yield expression can't be used in parameter SyntaxError: cannot use ?? unparenthesized within || and && expressions SyntaxError: character class escape cannot be used in class range in regular expression SyntaxError: continue must be inside loop SyntaxError: duplicate capture group name in regular expression SyntaxError: duplicate formal argument x SyntaxError: for-in loop head declarations may not have initializers SyntaxError: function statement requires a name SyntaxError: functions cannot be labelled SyntaxError: getter and setter for private name #x should either be both static or non-static SyntaxError: getter functions must have no arguments SyntaxError: identifier starts immediately after numeric literal SyntaxError: illegal character SyntaxError: import declarations may only appear at top level of a module SyntaxError: incomplete quantifier in regular expression SyntaxError: invalid assignment left-hand side SyntaxError: invalid BigInt syntax SyntaxError: invalid capture group name in regular expression SyntaxError: invalid character in class in regular expression SyntaxError: invalid class set operation in regular expression SyntaxError: invalid decimal escape in regular expression SyntaxError: invalid identity escape in regular expression SyntaxError: invalid named capture reference in regular expression SyntaxError: invalid property name in regular expression SyntaxError: invalid range in character class SyntaxError: invalid regexp group SyntaxError: invalid regular expression flag "x" SyntaxError: invalid unicode escape in regular expression SyntaxError: JSON.parse: bad parsing SyntaxError: label not found SyntaxError: missing : after property id SyntaxError: missing ) after argument list SyntaxError: missing ) after condition SyntaxError: missing ] after element list SyntaxError: missing } after function body SyntaxError: missing } after property list SyntaxError: missing = in const declaration SyntaxError: missing formal parameter SyntaxError: missing name after . operator SyntaxError: missing variable name SyntaxError: negated character class with strings in regular expression SyntaxError: new keyword cannot be used with an optional chain SyntaxError: nothing to repeat SyntaxError: numbers out of order in {} quantifier. SyntaxError: octal escape sequences can't be used in untagged template literals or in strict mode code SyntaxError: parameter after rest parameter SyntaxError: private fields can't be deleted SyntaxError: property name __proto__ appears more than once in object literal SyntaxError: raw bracket is not allowed in regular expression with unicode flag SyntaxError: redeclaration of formal parameter "x" SyntaxError: reference to undeclared private field or method #x SyntaxError: rest parameter may not have a default SyntaxError: return not in function SyntaxError: setter functions must have one argument SyntaxError: string literal contains an unescaped line break SyntaxError: super() is only valid in derived class constructors SyntaxError: tagged template cannot be used with optional chain SyntaxError: Unexpected '#' used outside of class body SyntaxError: Unexpected token SyntaxError: unlabeled break must be inside loop or switch SyntaxError: unparenthesized unary expression can't appear on the left-hand side of '**' SyntaxError: use of super property/member accesses only valid within methods or eval code within methods SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed TypeError: 'x' is not iterable TypeError: "x" is (not) "y" TypeError: "x" is not a constructor TypeError: "x" is not a function TypeError: "x" is not a non-null object TypeError: "x" is read-only TypeError: already executing generator TypeError: BigInt value can't be serialized in JSON TypeError: calling a builtin X constructor without new is forbidden TypeError: can't access/set private field or method: object is not the right class TypeError: can't assign to property "x" on "y": not an object TypeError: can't convert BigInt to number TypeError: can't convert x to BigInt TypeError: can't define property "x": "obj" is not extensible TypeError: can't delete non-configurable array element TypeError: can't redefine non-configurable property "x" TypeError: can't set prototype of this object TypeError: can't set prototype: it would cause a prototype chain cycle TypeError: cannot use 'in' operator to search for 'x' in 'y' TypeError: class constructors must be invoked with 'new' TypeError: cyclic object value TypeError: derived class constructor returned invalid value x TypeError: getting private setter-only property TypeError: Initializing an object twice is an error with private fields/methods TypeError: invalid 'instanceof' operand 'x' TypeError: invalid Array.prototype.sort argument TypeError: invalid assignment to const "x" TypeError: Iterator/AsyncIterator constructor can't be used directly TypeError: matchAll/replaceAll must be called with a global RegExp TypeError: More arguments needed TypeError: null/undefined has no properties TypeError: property "x" is non-configurable and can't be deleted TypeError: Reduce of empty array with no initial value TypeError: setting getter-only property "x" TypeError: WeakSet key/WeakMap value 'x' must be an object or an unregistered symbol TypeError: X.prototype.y called on incompatible type URIError: malformed URI sequence Warning: -file- is being assigned a //# sourceMappingURL, but already has one Warning: unreachable code after return statement Misc JavaScript technologies overview Execution model Lexical grammar Iteration protocols Strict mode Template literals Trailing commas Deprecated features MDN Your blueprint for a better internet. MDN About Blog Mozilla careers Advertise with us MDN Plus Product help Contribute MDN Community Community resources Writing guidelines MDN Discord MDN on GitHub Developers Web technologies Learn web development Guides Tutorials Glossary Hacks blog Mozilla Website Privacy Notice Telemetry Settings Legal Community Participation Guidelines Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.