易截截图软件、单文件、免安装、纯绿色、仅160KB

JAVASCRIPT初学者问题

// A simple function for sending a message
function sendMessage( msg, obj ) {
// If both a message and an object are provided
if ( arguments.length == 2 )
// Send the message to the object
obj.handleMsg( msg );
// Otherwise, assume that only a message was provided
else
// So just display the default error message
alert( msg );
}
// Call the function with one argument – displaying the message using an alert
sendMessage( "Hello, World!" );
// Otherwise, we can pass in our own object that handles
// a different way of displaying information
sendMessage( "How are you?", {
handleMsg: function( msg ) {
alert( "This is a custom message: " + msg );
}
});
// A function that takes any number of arguments and makes
// an array out of them
function makeArray() {
// The temporary array
var arr = [];
// Go through each of the submitted arguments
for ( var i = 0; i < arguments.length; i++ ) {
arr.push( arguments[i] );
}
// Return the resulting array
return arr;
}

其中有一段
sendMessage( "How are you?", {
handleMsg: function( msg ) {
alert( "This is a custom message: " + msg );
}
});

这段的语法看不太懂,请人详细解释一下,第二个参数的定义语法和过程,另外


相关问答:

javaScript 悬停浮动层定位

如何实现当鼠标悬停控件上时,出现该控件的尾部显示对应的层,鼠标移动到该层上进行相应的操作,当鼠标移除时(不在控件上也不在层上)层隐藏,

http://topic.csdn.net/u/20090830/23/5e5ded07-7216-46c2-9712- ......

javaScript悬停控件上的浮动层定位

如何实现当鼠标悬停控件上时,出现该控件的尾部显示对应的层,鼠标移动到该层上进行相应的操作,当鼠标移除时(不在控件上也不在层上)层隐藏,
HTML code:
<html>
<head>
<meta http-equiv= ......

javascript中是值是怎么交换了? - Java / Java相关

三个数x,y,z 比大小..
var x,y,z,t;
if (x>y) 
{t=x;x=y;y=t;} //交换x,y的值 
if(x>z) 
{t=z;z=x;x=t;}//交换x,z的值 
if(y>z) 
{t=y;y=z;z=t;}//交换z,y的值
这是 ......

在VC里调用javascript - VC/MFC / 基础类

void CWEHelperDlg::OnOK(){
CString code;

//调用VBSCRIPT,能弹出消息框,也能正确返回 hello
code = "function main()\r\n\tMsgBox \"ok\"\r\n\tmain=\"hello\"\r\nend functio ......

javascript坦克小游戏

第一部分
JScript code:

<script type="text/javascript">
static_id=0;
XPrang=function(srcBox,targetBox){
var x=Math.abs(srcBox.left-targetBox.left);
var ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号