function isObj(obj) {
return typeof obj === 'object' &&
Object.prototype.toString.call(obj).toLowerCase() === '[object object]' &&
!obj.length
}
// 测试promise
// function test(resolve, reject) {
// var timeOut = Math.random() * 2;
// console.log('set timeout to: ' + timeOut + ' seconds.');
// setTimeout(function () {
// if (timeOut < 1) {
// console.log('call resolve()...');
// resolve('200 OK');
// }
// else {
// console.log('call reject()...');
// reject('timeout in ' + timeOut + ' seconds.');
// }
// }, timeOut * 1000);
// }
// var p1 = new Promise(test);
// var p2 = p1.then(function (result) {
// console.log('成功:' + result);
// });
// var p3 = p2.catch(function (reason) {
// console.log('失败:' + reason);
// });
// 测试函数
let obj = {"errCode":0,"msg":"Welcome to my-api dev service 1.0...","data":null,"extra":null,"info":{"runTime":"0.00486秒"}}
// console.log(isObj(obj.data))
for(let i in {3}) {
alert(i)
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>hehe</title>
</head>
<body>
这是一个页面
</body>
</html>
body {
/* background-color: black; */
}