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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這個js控制臺的undefined是從哪里冒出來的?

這個js控制臺的undefined是從哪里冒出來的?

慕勒3428872 2019-03-04 13:15:28
沒想出來這個undefined是從哪里冒出來的。。。。<script>    count=0    function foo(){        t1=new Date()        console.log("foo執(zhí)行",t1.toLocaleString(),"count=",count)    }    t=new Date()    console.log("開始",t.toLocaleString())    var interval    interval=setInterval(function(){        if(count==5){            console.log("count=15,開始清理")            clearInterval(interval)            console.log("清理結束")            console.log(console.log("清理interval",t.toLocaleString(),"count=",count))        }        t=new Date()        setTimeout(foo,10000)        console.log("+","interval執(zhí)行",t.toLocaleString(),"count=",count)        count++    },1000)</script>>interval執(zhí)行 2018/1/30 下午5:41:52 count= 0testfiled.html:34 + interval執(zhí)行 2018/1/30 下午5:41:53 count= 1testfiled.html:34 + interval執(zhí)行 2018/1/30 下午5:41:54 count= 2testfiled.html:34 + interval執(zhí)行 2018/1/30 下午5:41:55 count= 3testfiled.html:34 + interval執(zhí)行 2018/1/30 下午5:41:56 count= 4testfiled.html:27 count=15,開始清理testfiled.html:29 清理結束testfiled.html:30 清理interval 2018/1/30 下午5:41:56 count= 5testfiled.html:30 undefinedtestfiled.html:34 + interval執(zhí)行 2018/1/30 下午5:41:57 count= 5testfiled.html:20 foo執(zhí)行 2018/1/30 下午5:42:02 count= 6testfiled.html:20 foo執(zhí)行 2018/1/30 下午5:42:03 count= 6testfiled.html:20 foo執(zhí)行 2018/1/30 下午5:42:04 count= 6testfiled.html:20 foo執(zhí)行 2018/1/30 下午5:42:05 count= 6testfiled.html:20 foo執(zhí)行 2018/1/30 下午5:42:06 count= 6testfiled.html:20 foo執(zhí)行 2018/1/30 下午5:42:07 count= 6
查看完整描述

4 回答

?
喵喔喔

TA貢獻1735條經(jīng)驗 獲得超5個贊

//大概沒注意,多寫了一層console.log();

console.log(console.log("清理interval",t.toLocaleString(),"count=",count))


// myVar的值為undefined

var myVar = console.log("清理interval",t.toLocaleString(),"count=",count);

console.log(myVar);


查看完整回答
反對 回復 2019-03-13
?
慕斯王

TA貢獻1864條經(jīng)驗 獲得超2個贊

console.log沒有返回值


        if(count==5){

            console.log("count=15,開始清理")

            clearInterval(interval)

            console.log("清理結束")

            //下面一嵌套了一層console.log

            console.log(console.log("清理interval",t.toLocaleString(),"count=",count))

        }


查看完整回答
反對 回復 2019-03-13
?
守著星空守著你

TA貢獻1799條經(jīng)驗 獲得超8個贊

這個undfined來自你調(diào)用的某個沒有手動return的方法。
這個方法可能是你寫的也可能是來自js內(nèi)部的,因為我們知道一個方法如果沒有手動return的話會默認返回undefined
最簡單的例子就是

console.log('anything');

的控制臺輸出,如下

https://img1.sycdn.imooc.com//5c88d7510001a2f803000076.jpg

這個undefined就來自js的console.log方法,因為他沒有手動return。


查看完整回答
反對 回復 2019-03-13
?
繁華開滿天機

TA貢獻1816條經(jīng)驗 獲得超4個贊

console.log(console.log("清理interval",t.toLocaleString(),"count=",count))

多了一個 console.log


查看完整回答
反對 回復 2019-03-13
  • 4 回答
  • 0 關注
  • 1191 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號