Javascript

function

2019/5/29

Function

function hi(name){
    console.log('Hello world') 
}

hi();

//'Hello world'
function hi(name){
    console.log('Hello '+ name) 
}

hi('Simba');

//'Hello Simba'
function hi(name='Simba'){
    console.log('Hello '+ name) 
}

hi('Bob');
//'Hello Bob'
hi();
//'Hello Simba'
function hi(){
    var output = 'Hello';
    for(var i in arguments){
        output += ' ' + arguments[i]
    }
    console.log(output);
}

hi();
//'Hello'
hi('Simba', 'Chris', '');
//Hello Simba Chris
參數為4個數字,代表AB兩點的座標,回傳值為兩點的直線距離,B點若空則為原點
參數為若干數字,回傳值為所有參數的平均

Javascript--function

By Simba Fs

Javascript--function

  • 94