第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

一個(gè)js面試題

一個(gè)js面試題

慕哥9229398 2018-08-01 17:05:19
function convert(s) {    console.log(s);//hi    s +=s.toUpperCase();    console.log(s);//hiHI}function funny(s) {    convert(s);    console.log(s);//hi}funny('hi');//求問為什么第三個(gè)是hi嗎?為什么不是hiHI
查看完整描述

3 回答

?
largeQ

TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊

.......你的變量是局部變量,你convert 函數(shù)沒有返回,funny中的s 變量,并沒有被改變,當(dāng)然還是hi了。。

查看完整回答
反對(duì) 回復(fù) 2018-08-04
?
慕無忌1623718

TA貢獻(xiàn)1744條經(jīng)驗(yàn) 獲得超4個(gè)贊

傳入convert()的s是值傳遞,并不會(huì)修改funny()中的s的值。所以在退出convert()不變.

查看完整回答
反對(duì) 回復(fù) 2018-08-04
?
狐的傳說

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超3個(gè)贊

  function convert(otherStr) {
        console.log(otherStr);//hi
        otherStr += otherStr.toUpperCase();
        console.log(otherStr);//hiHI
    }    function funny(str) {
        convert(str);
        console.log(str);//hi
    }
    funny('hi');

不知道這樣是不是能看明白一點(diǎn)

另外如果想第三個(gè)想輸出hiHI可以吧代碼改成如下

function convert(otherStr) {        
            console.log(otherStr);//hi
        otherStr += otherStr.toUpperCase();        
        console.log(otherStr);//hiHI
        return otherStr
    }    
function funny(str) {        
        //用一個(gè)變量來接收convert返回的值,當(dāng)然也可以不接收直接打印出來
        var res = convert(str);        
        console.log(res);//hiHI
    }
    funny('hi');


查看完整回答
反對(duì) 回復(fù) 2018-08-04
  • 3 回答
  • 0 關(guān)注
  • 1204 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)