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

Function - 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

Function

Baseline Widely available *

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

* Some parts of this feature may have varying levels of support.

JavaScript- Function. , (function(){}).constructor === Function, true.

In this article

Function()

Function. . , ( ) Global_Objects/eval. eval, Function , .

Function.prototype.arguments

. Function. arguments ( ).

Function.prototype.caller

, . , .

Function.prototype.displayName

.

Function.prototype.length

.

Function.prototype.name

.

Function.prototype.apply(thisArg [, argsArray])

this thisArg. Array.

Function.prototype.bind(thisArg[, arg1[, arg2[, ...argN]]])

, this thisArg. , .

Function.prototype.call(thisArg[, arg1, arg2, ...argN])

this . .

Function.prototype.toString()

. Object.prototype.toString.

Function

, Function, , .. . , , , Function. Global_Objects/eval -.

js
var x = 10;

function createFunction1() {
  var x = 20;
  return new Function("return x;"); //  |x|    |x|
}

function createFunction2() {
  var x = 20;
  function f() {
    return x; //  |x|    |x| 
  }
  return f;
}

var f1 = createFunction1();
console.log(f1()); // 10
var f2 = createFunction2();
console.log(f2()); // 20

, Node.js f1() ReferenceError, x . - , Node , x .

Specification
ECMAScript 2027 LanguageSpecification
# sec-function-objects


Web Proxy Viewer  |  New URL  |  Original Page