Skip to content
Tutorials Center
My learning

Topics

JavaScript Reference Β· Practical Pages

Deprecated and legacy features

Concept page on deprecated and legacy JavaScript: with, arguments.callee, escape(), substr(), getYear(), document.write(), __proto__ helpers and what to use instead.

JavaScript never removes features that could break existing websites. That is good for old pages and a trap for new code: many functions that still work were replaced years ago by safer or clearer ones. Some are deprecated (documented as "do not use"), some are legacy (kept only for compatibility), and a few work only in sloppy mode and are errors in strict mode, modules and classes.

This page lists the ones you are most likely to meet in old code or in autocomplete suggestions, and what to use today.

At a glance

Legacy feature Problem Use instead
with (obj) { ... } Ambiguous names, slow, error in strict mode A local variable or destructuring
arguments.callee Removed in strict mode A named function expression
arguments object Not a real array Rest parameters (...args)
escape() / unescape() Wrong for non-ASCII, deprecated encodeURIComponent() / decodeURIComponent()
substr() Deprecated, confusing arguments slice() or substring()
Date.prototype.getYear() Returns year minus 1900 getFullYear()
document.write() Blocks parsing, can wipe the page DOM methods, templates
__proto__, __defineGetter__() Non-standard style Object.getPrototypeOf(), Object.defineProperty()
String HTML methods (bold(), anchor(), fontcolor()) Produce obsolete HTML Create elements, use CSS
Octal literals like 010, \251 escapes Error in strict mode 0o10, Β©
var and hoisting tricks Function scope surprises let and const
Function.prototype.caller Banned in strict mode Pass arguments explicitly

with and arguments.callee

The with statement adds an object to the front of the scope chain, so any name might be a property or a variable depending on runtime data. That makes code unpredictable and prevents engine optimizations, so strict mode forbids it. arguments.callee referred to the running function; strict mode throws for it, and a named function expression does the same job.

JS with and callee versus modern code

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The arguments object

arguments is an array-like object (indexes and length, but no map() or filter()). Arrow functions do not have their own. Rest parameters give a real array and show intent in the signature.

JS arguments versus rest parameters

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Strings, dates and encoding

escape() and unescape() predate Unicode-aware encoding, and they encode non-ASCII characters in a non-standard way (as Latin-1 %E9, not UTF-8 %C3%A9), which servers rarely expect. substr(start, length) takes a length where slice(start, end) and substring(start, end) take an end position, and it is documented as a legacy feature. getYear() returns the year minus 1900 in the original design (so 125 for 2025).

JS Old functions versus today's

Press Run (or Ctrl + Enter) to see the console output here.

No output.

document.write(), __proto__ and friends

document.write() inserts text into the document stream while it is being parsed; called after the page has loaded it replaces the whole page. It also blocks parsing and browsers may ignore it for cross-origin scripts. Create nodes with DOM methods or insertAdjacentHTML() instead.

obj.__proto__ still works for reading and setting a prototype, but Object.getPrototypeOf(), Object.setPrototypeOf() and Object.create() are the standard tools. __defineGetter__(), __lookupGetter__() and the other __...__ helpers are superseded by Object.defineProperty() and getters in object literals.

The old string HTML wrappers ("x".bold(), "x".anchor("n"), "x".fontcolor("red")) generate presentational HTML tags and are kept only for compatibility. Build elements and style them with CSS.

Features that are gone or stay as traps

  • Octal literals (010 equals 8) are errors in strict mode; write 0o10.
  • with, arguments.callee, Function.prototype.caller, delete on a plain variable, duplicate parameter names are forbidden in strict mode.
  • Removed or discouraged browser APIs such as Object.observe(), showModalDialog(), unload handlers and synchronous XMLHttpRequest on the main thread.
  • for each...in, array comprehensions and let blocks were Firefox-only extensions and are not JavaScript.
  • eval() still works but blocks optimizations and is a security risk; see eval().

Usage notes

  • Deprecated does not mean removed. It means a better alternative exists, and the feature may be dropped in the future if usage is small enough.
  • Use strict mode or modules (they are always strict), and many of these features become errors you notice immediately.
  • Linters help. ESLint rules such as no-with, no-caller, no-restricted-properties and no-proto flag them.
  • Read old code with care. If you must keep a legacy construct, isolate it in one function with a comment.
  • Check a compatibility table before relying on any deprecated feature in new code, since browsers may start warning about it.

Browser support

Browsers still support nearly all of these features in sloppy mode for backward compatibility. Strict-mode errors for with, arguments.callee and octal literals apply everywhere. Features that browsers have removed (such as Object.observe()) are gone from current versions.