1.
class Cash {
constructor(cash) {
this.cash = cash;
var fen = cash%100;
var jiao = (cash/10)%10;
var yuan = (cash/100);
this.reCash = `${yuan}元${jiao}角${fen}分`;
}
add (obj1,obj2) {
return reCash;
}
};
var cash1 =new Cash(105);
var cash2 = new Cash(66);
var cash3 = cash1.add(cash2);
var cash4 = cash1.add(cash1,cash2);
var cash5 = new Cash(cash1+cash2);
console.log(${cash1}
,${cash2}
,${cash3}
);
2.在用户体验良好的基础上,采集页面所有的ajax请求的返回状态和响应时间。
3.用户自定义事件机制
实现on,可给对象绑定多个函数,且函数能多次触发。
emit方法:只绑定一个,且只触发一次。
4.IE11中可以使用 Promise对象。
5.A>B 表示选择A元素的所有子B元素。(直接子元素)
与A B的区别在于,A B选择所有后代元素,而A>B只选择一代。
6.
/[ABCD]{2,3}[a-z0-9]+/.test("CDEv");
/[ABCD]{2,3}[a-z0-9]+/.test("ABD5");
/[ABCD]{2,3}[a-z0-9]+/.test("CCab");
/[ABCD]{2,3}[a-z0-9]+/.test("CD1");
/[ABCD]{2,3}[a-z0-9]+/.test("BC");
7.
(4>=4)&&(5<=2)
[1,2,3].splice(1,1,2,3,4)
/[."]*/.test("http://image.163.com")
/[^"]*/.test("http://image.163.com")
true&& 0
0&&'s'
8.window.document
window.self
window.history
window.message
9.null == undefined
obj1 === obj2
var obj2 = new String(“1”);
var obj1 = new String(“1”);
window.history.pushState(null, null, “/name/orange”);
(function (a) {return this.value+a;}).bind({value:2}).call({value:3},4,5)
function f(a,b,c){console.log(arguments.callee.length);}
({x:0}==false)?true:false
{x:0}==false?true:false
[0]==false?true:false
([0])?true:false
var a=[];
typeof a
var taskk=[];
for(var i=0;i<5;i++){
((j)=>{
taskk.push(new Promise((resolve)=>{
setTimeout(()=>{
console.log(new Date,j);
resolve();
},1000*j)
}
));
}
)(i)
}
Promise.race(taskk).then(
()=>{
setTimeout(()=>{
console.log(new Date,i);
},0);
}
);
const task=[];
for(var i=0;i<5;i++){
((j)=>{
task.push(new Promise((resolve)=>{
setTimeout(()=>{
console.log(new Date,j);
resolve();
},1000*j)
}
));
}
)(i)
}
Promise.race(task).then(
()=>{
setTimeout(()=>{
console.log(new Date,i);
},0);
})
const task=[];
for(var i=0;i<5;i++){
((j)=>{
task.push(new Promise((resolve)=>{
setTimeout(()=>{
console.log(new Date,j);
resolve();
},1000*j)
}
));
}
)(i)
}
Promise.race(task).then(
()=>{
setTimeout(()=>{
console.log(new Date,i);
},2000);
})
const tasks=[];
for(var i=0;i<5;i++){
((j)=>{
tasks.push(new Promise((resolve)=>{
setTimeout(()=>{
console.log(new Date,j);
resolve();
},1000*j)
}
));
}
)(i)
}
Promise.race(tasks).then(
()=>{
setTimeout(()=>{
console.log(new Date,i);
},0);
})
const tasks=[];
for(var i=0;i<5;i++){
((j)=>{
tasks.push(new Promise((resolve)=>{
setTimeout(()=>{
console.log(new Date,j);
resolve();
},1000*j)
}
));
}
)(i)
}
Promise.race(tasks).then(
()=>{
setTimeout(()=>{
console.log(new Date,i);
},1000);
})
var task=[];
for(var i=0;i<5;i++){
((j)=>{
task.push(new Promise((resolve)=>{
setTimeout(()=>{
console.log(new Date,j);
resolve();
},1000*j)
}
));
}
)(i)
}
Promise.race(task).then(
()=>{
setTimeout(()=>{
console.log(new Date,i);
},0);
}
);
const task=[];
for(var i=0;i<5;i++){
((j)=>{
task.push(new Promise((resolve)=>{
setTimeout(()=>{
console.log(new Date,j);
resolve();
},1000*j)
}
));
}
)(i)
}
Promise.race(task).then(
()=>{
setTimeout(()=>{
console.log(new Date,i);
},0);
})
window.onhashchange=function(){console.log('hash change');}
window.history.pushState(null, null, "https://www.baidu.com/?name=orange");
window.onhashchange=function(){console.log('hash change');}
window.history.pushState(null, null, "https://segmentfaulcom/a/11900000072389/?name=orange");
window.onhashchange=function(){console.log('hash change');}
window.history.pushState(null, null, "https://segmentfaulcom/a/name=orange");
window.onhashchange=function(){console.log('hash change');}
window.history.pushState(null, null, "https://segmentfaulcom/a/11900000072389?name=orange");
window.onhashchange=function(){console.log('hash change');}
window.history.pushState(null, null, "https://segmentfaulcom/name=orange");
window.history.pushState(null, null, "?name=orange");
window.onpopstate=function(){console.log("1");}
window.history.pushState(null, null, "/name/orange");
7.
for(const i=0;i<5;i++){
setTimeout(function () {
console.log(i);
},i*1000);
}
setTimeout(function() {
console.log(1)
}, 0);
new Promise(function executor(resolve) {
console.log(2);
for( var i=0 ; i<10000 ; i++ ) {
i == 9999 ;
}
console.log(3);
}).then(function() {
console.log(4);
});
console.log(5);
for (var i = 0; i < 5; i++) {
setTimeout((function(i) {
console.log(i);
})(i), i * 1000);
}
for(var i=0;i<5;i++){
(function (k) {
setTimeout(function () {
console.log(new Date,k);
},k*1000);
})(i);
}
for(var i=0;i<5;i++){
setTimeout(function () {
console.log(new Date,i);
},1000);
}
console.log(new Date,i);
'meitu'.substr(-3,2)
console.log(1);
setTimeout(function(){
console.log(2);
},10);
console.log(3);
setTimeout(function(){
console.log(4);
},0)
document.onfocus
document.toggleClass()
document.cookie.replace(/;\s+/gim,"\",\"").
replace(/=/gim, "\":\"")
JSON.parse("{\"+ document.cookie.replace(/;\s+/gim,"\",\"").
replace(/=/gim, "\":\"") +\"}")
document.cookie.replace(/=/gim, "\":\"")
document.cookie.replace(/;\s+/gim,"\",\"")
"{\""+ document.cookie.replace(/;\s+/gim,"\",\"").
replace(/=/gim, "\":\"") +"\"}"
JSON.parse("{\""+ document.cookie.replace(/;\s+/gim,"\",\"").
replace(/=/gim, "\":\"") +"\"}")
"{\" +\"}"
\"" + "\"
\""
var s=1;
function p(s){
var s;
console.log(s);
s=3;
}
p(2);
(50|2)==50
let arr=[1..100]
let add=a=>b=>a+b
let {document:d0c,fetch}=window
let {document:dpc.fetch}=window
[].push(...[1,2])
var person="ni";
person.age=27;
console.log(person.age);
console.log(0);
var promise=new promise(function(resolve,reject){
console.log(1);
setTimeout(function(){
resolve();
console.log(2);
},1000)
})
console.log(3);
promise.then(function(){
console.log(4)
},function(){
console.log(5)
})
function h(){
var arr=[];
for(var i=0;i<10;i++){
arr[i]=function(){
return i;
};
}
return arr;
}
console.log(h()[1]());
Date.parse("1900-01-01");
encodeURI('http://m.ctrip.com?a=1&b=2')
function f(n){
for(var i=n;i>=0;i--){
setTimeout(function(){
console.log(i);
});
}
}
f(3)
![]