JavaScript-output in turn every 1 second (1-10)

I have done a written test that says to
make the program output 1~10 in turn every second

<script>
	for(var i=1; i<=10; i++;){
    
    
	//封装一个函数 执行异步操作
	(function(i){
    
    
	setTimeout(function(){
    
    
		conslon.log(i)
},1000*i)
})(i)
	}
</script>

Guess you like

Origin blog.csdn.net/weixin_45054614/article/details/113763317