Geekiter / geekiter.github.io

0 stars 0 forks source link

240304Note: 竹云 前端 #18

Open Geekiter opened 4 months ago

Geekiter commented 4 months ago

5.跨域问题

6.闭包,然后我谈到了内存泄露和溢出

7.怎么避免内存泄露溢出

8.原型和原型链,到达顶部没找到属性和方法返回什么

每个js对象在创建时,都会与另外一个对象关联起来,这个关联的对象就被称为原型。每个对象都可以从其原型继承属性方法。

function Person(name){
    this.name = name;
}

Person.prototype.sayHello = function(){
    ...
}

const alice = new Person("Alice");
alice.sayHello()

原型链

function Animal(name){
    this.name = name;
}

Animal.prototype.eat = function(){
    console.log("")
}

function Dog(name){
    Animal.call(this, name);
}

Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;

Dog.prototype.bark = function(){
    console.log("woof!");
}

cosnt buddy = new Dog("buddy");
buddy.eat()
buddy.bark()

9.原型链的顶部 Object.prototype null

10.vue的响应式原理

忘记说了怎么对数组进行响应式原理的?

const arrayProto = Array.prototype;
const arrayMethods = Object.create(arrayProto);

const methodsToPath = [
"push",
"pop",
"shift",
"unshift",
"splice",
"sort",
"reverse"
]
methodToPatch.forEach(function(method){
    const original = arrayProto[method];
    Object.defineProperty(arrayMethods, method, {
        value: function mutator(...args){
            const result = original.apply(this, args);
            const ob = this.__ob__;
            let inserted;
            switch(method){
                case "push";
                case "unshift";
                    inserted = args;
                    break;
                case "splice":
                    inserted = args.slice(2);
                    break;
            }
            if(inserted) ob.observeArray(inserted);
            ob.dep.notify();
            return result;
        },
        enumerable: false,
        writable: true,
        cofigurable: true
    })
})

11.vue2和vue3的区别

12.computed和watch的区别

13.路由的hash模式和history模式

14.常用通信方式

15.vuex。。×

16.持久化存储的缺点

16.自己定义的组件