//这种是函数公告;
//function box(){ //公告函数//没有参数
//alert(“只有调用才可以执行”)
//
//}
//alert(box());//直接调用函数’
//函数表达式
//var print=function(s){
//console.log(“dsdsd”);
//}
//
//print();
//
//var f = function f() {};
//function box(name,age){? //带参数形参;
//console.log(“你的姓名”+name+”年龄”+age);
//
//}
//box(“fengyuzhen”,18);? //调取参数不传的undeifd;
//
//function dd(){
//return “我被返回了”? //通过return把函数值返回;
//}
//console.log(dd()) ///调用函数返回的结果;
//
//function ddd(ad,nam){
//return “你好”+ad+”得到”+nam; //返回结果
//}
//
//alert(ddd(“ddsd”,122)) //调取结果
//
//function aaa(num1,num2){
//return num1*num2;? //赋值操作进行运算
//}
//var num=aaa(22,10);
//alert(num);?
//
//function aad(num111){
//if(num111<5)return;? //满足条件,就返回num ,遇见第一个reture ,就会终止函数,终止执行下去,不执行下面的代码,,没有返回undefined
//return 1000;? //返回就不执行了。
//}
//alert(aad(10));
//function box(){
//return arguments[0]+arguments[1];
//
//}
//alert(box(1,2,3,4,5));
//
//var foo=new Function(
//”return ‘hello world'”? //这种方式基本不使用;
//);
//function foo(){
//return “hello wold”;? //等同于这种
//}
//
//function f(){
//console.log(1)
//}
//f();
//
//function f(){
//console.log(2) //第一次的会被后面的覆盖;
//
//}
//f();
//函数可以调用自身,这就是递归(recursion)。下面就是通过递归,计算斐波那契数列的代码
function fib(num){
if(num===0) return 0;
if(num===1) return 1;
return fib(num-2)+fib(num-1)
}
console.log(fib(6))