7

想请教一下关于获取计时器内部数据的问题

 3 years ago
source link: https://www.v2ex.com/t/793012
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  JavaScript

想请教一下关于获取计时器内部数据的问题

  aglsv · 9 小时 20 分钟前 · 340 次点击
function a (){
 let a = 0
 a = 1
 let loader = setInterval(function () {
            abc () 
            clearInterval(loader)
        }, 1000)
        
 function abc (){
 	a +=1
 }
 
 return a
}

我的预想是 return 的 a 为 2,但是现在 return 的结果依旧是 1,请问这个该怎么解决啊


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK