美文网首页
前端 の 总结(二)

前端 の 总结(二)

作者: Charlescat | 来源:发表于2018-07-25 17:51 被阅读0次

    Vue:

    1.NextTick原理

    Vue 实现响应式并不是数据发生变化之后 DOM 立即变化,而是按一定的策略进行 DOM 的更新。

    Javascript:

    1.内置对象

    内置对象

    2.原型

    主要作用:通过prototype添加对象的属性和方法

    例:

    function cat(name){

        this.name = name

        this.say = ()=>{
            alert(this.name)
        }

    }

    let yjj = new cat('yjj')

    console.log(yjj.prototype)  //undefined  new出来的对象是没有原型的

    console.log(cat.prototype)  //object  构造的函数原型是个object

    3.instanceof

    对于值类型,你可以通过typeof判断,string/number/boolean都很清楚,但是typeof在判断到引用类型的时候,返回值只有object/function,你不知道它到底是一个object对象,还是数组,还是new Number等等。

    4.执行上下文

    例子:console.log(a)  // 报错

    ----------------------------------------

    console.log(a) // undefined

    let a

    ---------------------------------------

    console.log.log(a) // undefined

    let a  = 10

    ---------------------------------------

    console.log(cat) // function cat(){}

    function cat(){} //函数声明

    ----------------------------------------

    console.log(cat) // undefined

    var cat = function(){} //函数表达式

    结论: 1.变量 和 函数 声明 浏览器会 提前执行,后执行代码语句。

                2.函数声明会提前,而函数表达式不会,其实道理同上。

    相关文章

      网友评论

          本文标题:前端 の 总结(二)

          本文链接:https://www.haomeiwen.com/subject/poaopftx.html