zoukankan      html  css  js  c++  java
  • JS “区别” 汇总

    null和undefined的区别?

    null是一个表示"无"的对象,转为数值时为0;undefined是一个表示"无"的原始值,转为数值时为NaN。

    当声明的变量还未被初始化时,变量的默认值为undefined。 null用来表示尚未存在的对象,常用来表示函数企图返回一个不存在的对象。

    undefined表示"缺少值",就是此处应该有一个值,但是还没有定义。典型用法是:

    • 变量被声明了,但没有赋值时,就等于undefined。

    • 调用函数时,应该提供的参数没有提供,该参数等于undefined。

    • 对象没有赋值的属性,该属性的值为undefined。

    • 函数没有返回值时,默认返回undefined。

    null表示"没有对象",即该处不应该有值。典型用法是:

    • 作为函数的参数,表示该函数的参数不是对象。

    • 作为对象原型链的终点。

    documen.write和 innerHTML的区别?

    • document.write只能重绘整个页面
    • innerHTML可以重绘页面的一部分

     .call() 和 .apply() 的区别和作用?

    a.call(b,arg1,arg2…)
    
    apply(b,[arg1,arg2]) //apply只有2个参数,它将call的参数(arg1,arg2…)放在一个数组中作为apply的第二参数


    caller和callee的区别?

    caller 返回当前函数的 应用 函数

       function a(){
            b();
        }
        function c(){
            b()
        }
        function b(){
            console.log(b.caller);
        }
        a() // function a(){b();}
        c();// function c(){b();}

    callee 返回当前函数 本身

        function a(){
            b();
        }
        function c(){
            b()
        }
        function b(){
            console.log(b.arguments.callee);
        }
        a(); //  function b(){console.log(b.arguments.callee);}
        c();// function b(){console.log(b.arguments.callee);}
  • 相关阅读:
    Zero Downtime Upgrade of Oracle 10g to Oracle 11g Using GoldenGate — 1
    架构-MVVM:MVVM核心概念
    架构-MVVC:百科
    架构:目录
    架构:template
    JavaScript-Tool:Ext JS
    JavaScript-Tool:jquery.tree.js-un
    JavaScript-Tool:wdtree
    C#:C# 运算符
    C#:目录
  • 原文地址:https://www.cnblogs.com/xianglx/p/5676993.html
Copyright © 2011-2022 走看看