手写系列

手写ajax

var xmlhttp
if(window.XMLHttpRequest){
  xmlhttp= new XMLHttpRequest()
}else{
   xmlhttp =new ActiveXObject('Microsoft XMLHTTP')
}
xmlhttp.onreadystatechange  = function(){
  if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
    console.log(xmlhttp.responceText)
}
  }
xmlhttp.open('get','/',true)
xmlhttp.send()

手写迭代器

function iteartor(arr){
const index = 0
return {
next:function(){
return index<arr.length?{
value:arr[index++] , done:false}:{
value:undefined , done: true}
}
}
}

猜你喜欢

转载自www.cnblogs.com/dengsicode/p/12728271.html
今日推荐