3
头图

join us!

Mountain" , to provide front-end developers with technical information and a series of basic articles. For a better user experience, please move to our official website novices (1611c9ae19f4bf https://xhs-rookies.com/ ) to learn and get the latest articles in time.

"Code tailor" , if you are interested in our article or want to make some suggestions, follow "Novices of Xiaohe Mountain" , contact us, you can also watch it on WeChat Our article. Every suggestion or approval is a great encouragement to us!

Interview series are updated from time to time, please stay tuned

Preface

This column focuses on explaining the JavaScript/ES6 interview questions in the interview.

Note: This column will only involve key content and will not be expanded. For some topics that need to expand knowledge points, we will put the expanded content and overall detailed information behind each topic, and you can check it by yourself.

JavaScript/ES6:

JavaScript/ES6
The difference between const and let
What are the basic data types
How to judge the basic data type
What is returned by typeof null and why
Closures and the usage of closures
What are the traversal methods
for..in for..of The difference between the two
What are the new features of ES6
The difference between arrow functions and ordinary functions.
What is the prototype chain
How to use Promise
What is the principle of Promise

Problem analysis

One, the difference between const and let

  • const cannot be changed when modifying the basic type. When modifying the reference type (object, array), the address pointed to by the pointer cannot be changed, and the internal data can be changed. let Modification Any type can be modified
  • const must be initialized after declaration, and let does not need

For more details, please see: What is the difference between Var, Let and Const in JavaScript

2. What are the basic data types?

Seven basic data types: undefined , null , boolean , Number , String , BigInt , Symbol

Reference data type: Object

Third, basic data type judgment

  • typeof
  • instanceof
  • Object.prototype.toString()

4. What is returned by typeof null and why

typeof null returns Object , because Object low three machine code is stored in the underlying 000 , and null stored machine code for the whole 0 , so use typeof is determined directly determines Object

Note: Questions 2, 3, and 4 are consecutive

For more details, please see: Talking about the principle of typeof and instanceof

V. Closures and the usage of

Closure: A function that can access free variables (free variables are neither function parameters nor variables inside the function)

application scenario:

  • Execute function immediately

advantages:

  • Variables can be stored for a long time

drawback:

  • Too much impact on memory

For more details, please see: closure

Six. What are the traversal methods?

Commonly used traversal methods: map , forEach , filter , for...in , for...of

Seven, the difference between for...in and for...of

for...in used to traverse the object key value and the value on the prototype chain

for...of value value used to traverse the object

8. What are the new features of ES6

  • letconst
  • Arrow function
  • promise
  • async and await
  • setmap
  • class
  • Symbol

Nine, the difference between arrow functions and ordinary functions

The main difference is that the arrow function does not have this and argument

without this, then

  • Cannot be used as a constructor
  • No prototype
  • Cannot change the this point call , bind , apply
  • Its this always points to the global execution environment in which it was defined

Ten, what is the prototype chain

The prototype chain is a chain structure composed of proto

More details: prototype chain

eleven, Promise

Be sure to master the Promise , such as then , all , race , resolve , reject

The key point of Promise

  • Three states
  • Chain call

More details: Graphic Promise

Preview of the next section

In the next section, we will bring you the HTML/CSS questions of 0611c9ae1a02da, so stay tuned!


小和山的菜鸟们
377 声望2.1k 粉丝

每日进步的菜鸟,分享前端学习手册,和有心学习前端技术的小伙伴们互相探讨,一同成长。