My boss recently asked me to do the front end interview, and I came up with the following questions. The company’s business is biased towards small procedures, so vUE what basically did not ask, are partial basic questions. Because also do not have the experience of this respect, have a problem so, hope each big guy corrects. Let’s cut to the chase

The title

  • JavaScript data type

Value types: String, Number, Boolean, Null, Undefined, Symbol (ES6). Reference data types: Object, Array, Function.

Personally, I think this is a very simple question, but unfortunately, 80% of people can’t answer it completely. The answer you’d like to hear is: value types and reference types, blah, blah, blah.

  • What is the difference between deep copy and shallow copy, and how to implement deep copy of objects

Parse json. parse (drawback: values containing undefined, function, and symbol are ignored). 2. Recursive replication.

// Copy recursivelyfunction deepCopy(obj) {
      var result = Array.isArray(obj) ? [] : {};
      for (var key in obj) {
        if (obj.hasOwnProperty(key)) {
          if (typeof obj[key] === 'object') { result[key] = deepCopy(obj[key]); }}else{ result[key] = obj[key]; }}}return result;
    }
Copy the code

3. Libraries (Lodash, jQuery, etc.) have deep-copy methods that 70% of them don’t even know the reference type. And then you can only partially know, you can only basically say one way, which is pretty good.

  • Give a brief overview of js closures and their implementation

In short, it is to form a stack environment that is not destroyed. It can be used to privatize variables and to create static methods (called directly from the class name without instantiation). Simple implementation:

var add = (function () {
    var counter = 0;
    return function () {returncounter += 1; }}) (); add(); add(); add(); // Finally counter is 3Copy the code
  • var let constThe difference between.

The difference is also quite many, or the more the better, the average person can name a few. For example, the scope difference, const is constant. That’s pretty much it, but it would be a plus if you could say something else.

  1. Temporary dead zones: As long as the let command exists in the block-level scope, its declared variables are “binding” to the zone, no longer subject to external influence. The code below is reporting an error because of a temporary dead zone, which is tricky to define, but it would be nice to know when the following is going to happen, or to know that this exists.
var tmp = 123;
if (true) {
  tmp = 'abc'; // ReferenceError
  let tmp;
}
Copy the code
  1. letandconstDuplicate declarations are not allowed. andconstIt can only be assigned at declaration time (this is easy, but many people really don’t know).
  • ES6 and ES5 differences, or what is added to ES6 compared to ES5

There are so many, almost no one can say them all, but the more the better, as many as you can say. Check it out here. Es6.ruanyifeng.com/ is also a plus if it can name a few unusual points.

  • CSS selector weights:

Most basic:! Important (infinite)> inline (1000)>ID selector (100)>class selector (10)> tag selector (1) Bonus: attribute selector or pseudo-class (10), pseudo-element (1), wildcard selector * (0) etc.

  • Talk about the performance optimization of wechat applets (wechat applets are the main business of the company)

Lazy loading, reducing setData and unnecessary setData, adding keys to list rendering, using caching properly, using event communication properly, etc.

  • The difference between token and cookie

Is a topic that can be said for a long time, as much as possible, there is no need to do, recommend a article, www.jianshu.com/p/c33f5777c… . Or you can do it yourself

  • A brief description of the vUE bidirectional binding implementation

No one expects you to implement a VUE, but learning other people’s ideas and principles will help you improve your skills. The simple answer is: Before Vue3.0, get and set were overwritten using Object.defineProperty, whereas Vue3.0 used proxies. Specific realization principle, here also do not repeat, later will give an article to write specifically.

Write in the last

I interviewed about ten people with this set of questions, most of them are about three years in front, the most powerful can only answer sixty or seventy percent, most of them can only answer thirty percent, I doubt whether the topic is too difficult. Alas ~ heart tired.

Personally, I think they are all basic knowledge, and I rarely ask about the framework, because I think the framework should not be a big problem if the foundation is good. These topics, but also I used to interview often encountered some, so just out of these.