[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Errors/Unnamed_function_statement [Back]  [Original]

SyntaxError: function statement requires a name( ) - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

SyntaxError: function statement requires a name( )

SyntaxError:   (Edge)
SyntaxError:     [Firefox]
SyntaxError:   ( [Chrome]

In this article

SyntaxError

?

function, . , , , IIFE, .

vs

( ) , :

js
function () {
  return 'Hello world';
}
// SyntaxError: function statement requires a name

() :

js
var greet = function () {
  return "Hello world";
};

, , IIFE ( ), , , . :

js
(function () {})();

function . :

js
function Greeter() {
  german: function () {
    return "Moin";
  }
}
// SyntaxError:    

, :

js
function Greeter() {
  german: function g() {
    return "Moin";
  }
}

, . function.

js
var greeter = {
  german: function () {
    return "Moin";
  },
};

, . .

js
promise.then(
  function() {
    console.log("success");
  });
  function() {
    console.log("error");
}
// SyntaxError: function statement requires a name

:

json
promise.then(
  function() {
    console.log("success");
  },
  function() {
    console.log("error");
  }
);


Web Proxy Viewer  |  New URL  |  Original Page