Correction status:Uncorrected
Teacher's comments:
var obj = new Object();
obj.name="bo";
obj.age = "18";
obj.abb = function(){
console.log('我说话');
};
obj.abb();
var obj = {name: "bo", age: "18"};
obj.addr = "shen zhen";
obj.speak = function(str){
console.log('我会说话了【'+str+'】');
}
obj.speak('hello js object');
var obj = {
name:"bo",
age:18,
speek:function(str,str2){
console.log('我说话了: '+str);
console.log('str2='+str2);
},
speek2:function(){
this.speek('speek2 调用了speek','aa');
}
}
obj.speek2();
setTimeout()
只执行一次延时
setTimeout(function () {
console.log('页面加载');
}, 3000);
setInterval()
一直执行,使用 clearInterval()
结束
var haak = setInterval(function(){
console.log('this is setInterval()');
clearInterval(haak);
},1000);
function send(){
var flag=10;
var txt = document.getElementById('btn').textContent;
var timer = setInterval(function(){
document.getElementById('btn').textContent = flag+'秒后重试';
flag--;
if(flag==0){
document.getElementById('btn').textContent = txt;
clearInterval(timer);
}
},1000);
}