以下代码的输出是什么? [英] What will be the output of the following code?

查看:76
本文介绍了以下代码的输出是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  function  setValue(fName,lName,age){
setCustInfo(fname);
displayCustInfo(lname);
}

function setCustInfo(name){
alert( 名称设置为: + name);
}

function displayCustinfo(name){
alert( 名称显示为: + name);
setValue( James Bond 30 );
}









更正了格式和/或语法问题。

已添加 pre 标签。

[/编辑]

解决方案

< blockquote>除非在代码中调用任何这些函数,否则不会发生任何事情。


根本没有意义。建议您阅读 JavaScript对象 [ ^ ]


如果使用上述函数,我们将不会获得displayCustinfo()的警告功能名称不同(Capital I,small i)。如果我们更改它们,那么我们将收到警报消息。



这是我尝试过的代码。如果任何人找到更好的代码,请在这里提供。







< button onclick ='setValue(James,Bond,30)'>提交< / button> 





脚本:< br $>


函数setValue(fname,lname,age){

setCustInfo(fname);

displayCustinfo(lname);

}



函数setCustInfo(name){

alert(名称设置为:+名称);

}



函数displayCustinfo(name){

alert(名称显示为:+ name );



}


function setValue(fName,lName,age){
    setCustInfo(fname);   
    displayCustInfo(lname); 
}

function setCustInfo(name){   
    alert("The name is set as :" + name); 
}

function displayCustinfo(name){
    alert("Name is displayed as :" + name);   
    setValue("James","Bond",30);
}




[Edit member="Tadit"]
Corrected formatting and/or grammatical issues.
Added pre tags.
[/Edit]

解决方案

Nothing will happen, unless any of these functions is called in the code.


It does not make sense at all. Suggest you read out on JavaScript Objects[^]


If using the above function's we will not get the alert of displayCustinfo() as the function name is different(Capital I, small i). If we change them then we will get the alert messages.

Here is the code I have tried. If any one find better code please provide here.



<button onclick='setValue("James","Bond",30)'>Submit</button>



script:

function setValue(fname,lname,age){
setCustInfo(fname);
displayCustinfo(lname);
}

function setCustInfo(name){
alert("The name is set as :" + name);
}

function displayCustinfo(name){
alert("Name is displayed as :" + name);

}


这篇关于以下代码的输出是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆