前端笔记:对象2

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值