Function.caller - 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 Веб-технологии для разработчиков JavaScript Справочник по JavaScript Стандартные встроенные объекты Function Function.caller Theme OS default Light Dark Русский Remember language Learn more Deutsch English (US) Español Français 日本語 한국어 Português (do Brasil) Русский 中文 (简体) 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.caller Не стандартно: Эта функция не стандартизирована. Мы не рекомендуем использовать нестандартные функции в действующих проектах, так как их поддержка браузерами ограничена, а поведение может измениться или быть удалено. Тем не менее, в некоторых случаях, когда нет стандартного решения, они могут быть подходящей альтернативой. In this article Сводка Описание Примеры Спецификации Совместимость с браузерами Смотрите также Сводка Свойство function.caller возвращает функцию, которая вызвала указанную функцию. Описание Если функция f была вызвана из кода самого верхнего уровня, значение f.caller будет равно null, в противном случае значение будет равно функции, вызвавшей f. Это свойство пришло на замену удалённого свойства arguments.caller объекта arguments. Специальное свойство __caller__, возвращающее объект активации вызывающей функции и, таким образом, позволяющее восстанавливать стек вызовов, было удалено по соображениям безопасности. Примечания Обратите внимание, что в случае рекурсии, вы не сможете воссоздать стек вызовов, используя это свойство. Пусть у нас есть функции: js function f(n) { g(n - 1); } function g(n) { if (n > 0) { f(n); } else { stop(); } } f(2); В момент вызова функции stop(), стек вызовов имеет следующий вид: f(2) -> g(2) -> f(2) -> g(1) -> f(1) -> g(0) -> stop() Следующее условие верно: stop.caller === g && f.caller === g && g.caller === f так что если вы попытаетесь оттрассировать стек в функции stop() подобным образом: js var f = stop; var stack = "Трассировка стека:"; while (f) { stack += "\n" + f.name; f = f.caller; } то этот цикл никогда не остановится. Примеры Пример: проверка значения свойства caller функции Следующий код проверяет значение свойства caller функции. js function myFunc() { if (myFunc.caller == null) { return "Эта функция была вызвана из верхнего уровня!"; } else { return "Эта функция была вызвана из " + myFunc.caller; } } Спецификации Не является частью какой-либо спецификации. Реализована в JavaScript 1.5. Совместимость с браузерами Enable JavaScript to view this browser compatibility table. Смотрите также Ошибка реализации в SpiderMonkey: Firefox bug 65683 Help improve MDN Was this page helpful to you? Yes No Learn how to contribute This page was last modified on 29 июн. 2026 г. by MDN contributors. View this page on GitHub • Report a problem with this content Filter sidebar Clear filter input Стандартные встроенные объекты Function Конструктор Конструктор Function() Методы экземпляра Function.prototype.apply() Function.prototype.bind() Function.prototype.call() Function.prototype.toString() [Symbol.hasInstance]() Свойства экземпляра Function.displayName Function.length Function.name prototype Function.arguments Function.caller Наследование Object/Function Статические методы Function.prototype.apply() Function.prototype.bind() Function.prototype.call() Function.prototype.toString() [Symbol.hasInstance]() Статические свойства Function.displayName Function.length Function.name prototype Function.arguments Function.caller Методы экземпляра Object.prototype.__defineGetter__() Object.prototype.__defineSetter__() Object.prototype.__lookupGetter__() Object.prototype.__lookupSetter__() Object.prototype.hasOwnProperty() Object.prototype.isPrototypeOf() Object.prototype.propertyIsEnumerable() Object.prototype.toLocaleString() Object.prototype.toString() Object.prototype.valueOf() Свойства экземпляра Object.prototype.__proto__ Object.prototype.constructor 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.