本文介绍了为什么arguments.callee.caller.name未定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何走到这一步并不会提醒http://127.0.0.1/sendRequest? (可在)

 无功富= {
    sendRequest将:功能(){
        警报(bar.getUrl());
    }
};VAR栏= {
    的getURL:功能(){
        回报http://127.0.0.1/'+ arguments.callee.caller.name;
    }
};foo.sendRequest();


解决方案

在对象文本放置一个值,因为你正在做的,不影响价值可言。

 无功富= {
    发送请求: ...

的函数值仅由功能前pression,其中不包含名称的影响

  ...功能(){
        警报(bar.getUrl());
    }

您需要包括你在函数前pression自己想要的名字。

 无功富= {
    sendRequest将:函数sendRequest将(){

How come this doesn't alert "http://127.0.0.1/sendRequest"? (Available at http://jsfiddle.net/Gq8Wd/52/)

var foo = {
    sendRequest: function() {
        alert(bar.getUrl());
    }
};                    

var bar = {
    getUrl: function() {
        return 'http://127.0.0.1/' + arguments.callee.caller.name;
    }
};

foo.sendRequest();
解决方案

Putting a value in an object literal, as you're doing, doesn't affect the value at all.

var foo = {
    sendRequest: ...

The function value is only affected by the function expression, which doesn't contain a name.

             ... function() {
        alert(bar.getUrl());
    }

You need to include the name you want in the function expression itself .

var foo = {
    sendRequest: function sendRequest() {

这篇关于为什么arguments.callee.caller.name未定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:31