Blogger Information
Blog 61
fans 1
comment 0
visits 70100
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0505-用函数表达式求三个数值之和
我的博客
Original
1308 people have browsed it
//方法1:函数内部打印

var num=function(x,y,z){
   var i=x+y+z;
   console.log('x+y+z=' + i);
   document.write('x+y+z=' + i)

};    //匿名函数 花括号末尾要加分号。

num(10,20,30);



//方法2:函数外部打印调用

var num=function(x,y,z){
   var i=x+y+z;
   return i;
};    //匿名函数 花括号末尾要加分号。

rep=num(10,20,30);    //把返回值赋值给一个变量,方便调用,不能直接调用函数内部局域变量。
console.log('x+y+z=' + rep);
document.write('x+y+z=' + rep +'<br/>');
document.write('x+y+z=' + num(11,12,13));

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post