MDN’s new design is in Beta! A sneak peek:

Diese Übersetzung ist unvollständig. Bitte helfen Sie, diesen Artikel aus dem Englischen zu übersetzen.

This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.


The property returns the name of the function.

Property attributes of
Writable no
Enumerable no
Configurable no


The name property returns the name of a function, or an empty string for anonymous functions:

function doSomething() {}

console.log(; // logs "doSomething"

Functions created with the syntax new Function(...) or just Function(...) have their name property set to an empty string. In the following examples anonymous functions are created, so name returns an empty string:

var f = function() {};
var object = {
  someMethod: function() {}

console.log( == ''); // true
console.log( == ''); // also true

You can define a function with a name in a function expression:

var object = {
  someMethod: function object_someMethod() {}
console.log(; // logs "object_someMethod"

try { object_someMethod } catch(e) { console.log(e); }
// ReferenceError: object_someMethod is not defined

You cannot change the name of a function, this property is read-only:

var object = {
  // anonymous
  someMethod: function() {}
}; = 'someMethod';
console.log(; // empty string, someMethod is anonymous


You can use to check the "class" of an object:

function a() {}

var b = new a();

console.log(; // logs "a"

However the instanceof Operator should be preferred for type checking.


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
Die Definition von 'name' in dieser Spezifikation.
Standard Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 33 (Ja) Nicht unterstützt (Ja) (Ja)
Configurable: true 43 38 (38) ? ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Ja) (Ja) (Ja) Nicht unterstützt (Ja) (Ja)
Configurable: true ? ? 38.0 (38) ? ? ?

Schlagwörter des Dokuments und Mitwirkende

 Mitwirkende an dieser Seite: MoritzKn, DavidVollmers
 Zuletzt aktualisiert von: MoritzKn,