zoukankan      html  css  js  c++  java
  • 函数易错知识点整理

    函数易错题目合集

    var f1 = function f2(){};  
    f1.name  //"f2"
    
    
    var f1 = function f2(){};  
    f2.name  //报错:f2 is not defined
    
    var f1 = function f2(){}; 
    console.log(f2)  
    //f2 is not defined(f2 不存在,而且 f2 不是 undefined)
    
    function f(){console.log(this)}; 
    f.call(1)  //Number 对象 1
    
    function f(){'use strict' console.log(this)}; 
    f.call(1)  //1
    
    function f(){console.log(this)}; 
    f.call()  //Window 对象
    
    function f(){'use strict' console.log(this)};  
    f.call()   //undefined
    
    var a = console.log(1); 
    a  //undefined
    
    function f(){ return 1}; a = f ; 
    a //函数 f
    
    function f(){ return 1}; var a = f.call() ; 
    a //1
    
    var a = 1,2; 
    a //报错
    
    var a = (1,2); 
    a //2
    
    var a = (1, console.log(2)); 
    a //undefined
    
    
    function f(){
        return function f2(){}
    }
    var a = f.call()
    a //函数 f2
    
    
    function f(){
        return function f2(){}
    }
    var a = f.call()
    var b = a.call()
    b //undefined
    
    
    function f1(){
        console.log(this)
        function f2(){
        }
    }
    var obj = {name: 'obj'}
    f1.call( obj )
    //obj 对象
    
    
    function f1(){
    
        function f2(){
            console.log(this)
        }
        f2.call()
    }
    var obj = {name: 'obj'}
    f1.call( obj )
    //Window 对象
    
    
    function f1(){
        console.log(this) // 第一个 this
        function f2(){
            console.log(this) // 第二个 this
        }
        f2.call()
    }
    var obj = {name: 'obj'}
    f1.call( obj )
    //为什么两个 this 值不一样?
    //this 就是 call 的第一个参数,第一个 this 对应的 call 是 f1.call(obj),第二个 this 对应的 call 是 f2.call()
    //this 和 arguments 都是参数,参数都要在函数执行(call)的时候才能确定
  • 相关阅读:
    浅水方程
    Delaunay三角剖分算法
    计算机图形学知名期刊杂志(转载)
    Sql 主键自增
    Skinny triangle
    开源免费天气预报接口API以及全国所有地区代码!!
    Navier Stokes(纳维叶-斯托克斯)方程
    java.util.Date_与_java.sql.Date互转_及_字符串转换为日期时间格式
    2015最后一天
    html标签
  • 原文地址:https://www.cnblogs.com/nolaaaaa/p/9085355.html
Copyright © 2011-2022 走看看