isNaN
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
function isNaN1(num){
var res = Number(num) + '';
if(res == 'NaN'){
return true;
}else{
return false;
}
}
console.log(isNaN1('123'));
</script>
</body>
</html>
``
this
```javascript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var a = '1';
function test(){
var a = '2';
this.a = '3';
console.log(a);
}
test();
new test();
var obj = {};
console.log(a);
console.log({} == {});
console.log(obj1 = obj);
console.log(obj1 == obj);
var b = 5;
function text(){
b = 0;
console.log(b);
console.log(this.b);
var b;
console.log(b);
}
text();
new text();
</script>
</body>
</html>在这里插入代码片
foo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
function foo(){
bar.apply(null, arguments);
bar.call(null, arguments)
}
function bar(){
console.log(arguments);
}
foo(1, 2, 3, 4, 5);
//bar() --> bar.call(arguments) --> bar(arguments)
</script>
</body>
</html>
instanceof
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
function Car(){}
var car = new Car();
function Person(){}
var p = new Person();
var a = [];
console.log(car instanceof Car);
console.log(car instanceof Object);
console.log([] instanceof Array);
console.log([] instanceof Object);
console.log({} instanceof Object);
console.log(a.constructor);
console.log(a instanceof Array);
//A对象的原型里到底有没有B的原型
</script>
</body>
</html>