• 经典笔试题


    foo()
    var foo
    
    function foo() {
        console.log(1)
    }
    
    foo = function () {
        console.log(2)
    }
    console.log(foo)
    
    function Foo() {
        getName = function () {
            console.log(1);
        };
        return this;
    }
    
    Foo.getName = function () {
        console.log(2);
    };
    Foo.prototype.getName = function () {
        console.log(3);
    };
    var getName = function () {
        console.log(4);
    };
    
    function getName() {
        console.log(5);
    }
    
    console.log(getName)
    
    Foo.getName();
    getName();
    Foo().getName();
    getName();
    new Foo.getName();
    new Foo().getName();
    new new Foo().getName();
    
    
    function Foo() {
        getName = function () {
            console.log(1);
        };
        return this;
    }
    
    Foo.getName = function () {
        console.log(2);
    };
    Foo.prototype.getName = function () {
        console.log(3);
    };
    var getName = function () {
        console.log(4);
    };
    
    function getName() {
        console.log(5);
    }
    
    console.log(Foo)
    console.log(Foo.getName)
    
    
    // -----------------------------------------------------------
    // 1、
    function A() {
        console.log(1)
    }
    
    function fn() {
        A = function () {
            console.log(2)
        }
        return this
    }
    
    fn.A = A
    fn.prototype = {
        A: () => {
            console.log(3)
        }
    }
    console.log(fn.A === A)
    console.log(fn)
    console.log(fn.A === A)
    console.log(fn.A === A)
        .console.log(typeof fn)
    
    // 1,1 2 2 3 3
    
    A()
    fn.A()
    fn().A()
    new fn.A()
    new fn().A()
    new new fn().A()
    
    
    // 2、 自执行函数中的this都指向window
    var x = 2; // 4 16
    var y = {
        x: 3,
        z: (function (x) {
            console.log(this)
            this.x *= x
            x += 2
            return function (n) {
                this.x *= n
                x += 3
                console.log(x)
            }
        })(x)
    }
    
    var m = y.z
    m(4)
    y.z(5)
    console.log(x, y.x)
    
    
    // 3、
    // js== 比较规则
    // 对象 == 字符串 -> 对象.toString()变为字符串再来比较
    // null == undefined 相等,但是和其他值比较就不再相等了
    // NaN == NaN  false  不相等
    // 剩下的都是转换为数字进行比较 (引用类型和数字进行比较时,先执行toString方法,然后调用number(),最后再进行比较)
    
    var a = '?'; // 如何设置a使下面的能够执行
    a = {
        i: 1,
        toString() {
            return this.i++
        }
    }
    if (a == 1 && a == 2 && a == 3) {
        console.log(1) //
    } else {
        console.log(2)
    }
    
    
    //4、
    var x = 0, y = 1
    
    function fn() {
        x += 2
        fn = function (y) {
            console.log(y + (--x))
        }
        console.log(x, y)
    }
    
    fn(3)
    fn(4)
    console.log(x, y)
    
    
    //5、
    setTimeout(() => {
        console.log(1)
    }, 2)
    console.log(2)
    setTimeout(() => {
        console.log(3)
    }, 10)
    console.log(4)
    console.time('Aa')
    for (let i = 0; i < 900000; i++) {
    
    }
    console.timeEnd('AA')
    console.log(5)
    setTimeout(() => {
        console.log(6)
    }, 800)
    console.log(7)
    setTimeout(() => {
        console.log(8)
    }, 15)
    console.log(9)
  • 相关阅读:
    Requests接口测试(五)
    Requests接口测试(四)
    Requests接口测试(一)
    软件测试杂谈(学习思路、学习方法、面试技巧、后期发展、职业规划等)
    Requests接口测试(三)
    Requests接口测试(二)
    Python基础入门-列表解析式
    Python基础入门-集合
    Jmeter接口测试-完成任务API
    Jmeter接口测试-基于nodejs的to do list项目说明
  • 原文地址:https://www.cnblogs.com/cazj/p/14374833.html
Copyright © 2020-2023  润新知