


Share some selected web front-end interview questions worth collecting (with answers)
This article summarizes some selected Web front-end interview questions worth collecting (with answers). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
js interview questions
-
1.js data type
- Basic data types
Number, String, Boolean, Null, Undefined, Symbol, bigInt - Reference data types
object, Array, Date, Function, RegExp
- Basic data types
-
2. Promotion of js variable and function declarations
- The declaration of variables and functions in js will be promoted to the top to execute the
- function The promotion is higher than the promotion of variables
- If an external variable with the same name is declared using var inside the function, the function will no longer search upward.
- Anonymous functions are not promoted.
-
3. Closure
- A closure is a function that can read the internal variables of other functions
- Basically, a closure It is a function that returns a function inside.
- Benefits
- You can read the variables inside the function
- Keep the variables in the memory all the time
- You can encapsulate objects Private properties and private methods
- Disadvantages
- It consumes more memory and may cause memory overflow if used improperly
-
4. The difference between == and ===
- == is equality in a non-strict sense
- Equal values are equal
- === is equality in the strict sense, and will compare the data types and value sizes of both sides
- Equal only when the value and reference address are equal
- == is equality in a non-strict sense
-
5. this
- this always points to the direct caller of the function
- If there is a new keyword, this points to the object from new
- In the event, this points to the object that triggered the event
-
6. How to traverse js arrays and objects
- for in
- for
- forEach
- for-of
- ##7. The difference between map and forEach
- The forEach method is the most basic method, which is traversal and looping. There are three parameters passed by default: the content of the traversed array
- , the array index index, and the current traversed array Array
map method, the basic usage is the same as forEach, but different, it will return a new array, so callback - needs to have a return value, if not, it will return undefined
- , the array index index, and the current traversed array Array
- 8. What is the difference between arrow functions and ordinary functions?
- The this object in the function body is the object where it is defined, not the object where it is used
- It cannot be used as a constructor, that is, the new command cannot be used, otherwise an error will be thrown
- The arguments object cannot be used, and the object does not exist in the function body. If you want to use it, you can use the Rest parameter instead
- The yield command cannot be used, so the arrow function cannot be used as the Generator function
- 9. Same-origin policy
- The same origin refers to the same domain name, protocol, and port number
- 10. How to solve cross-domain issues
- jsonp cross-domain
- document.domain iframe cross-domain
- nodejs middleware proxy cross-domain
- The backend sets the secure domain name in the header information
- 11. Restrictions of strict mode
- Variables must be declared before use
- The parameters of the function cannot have the same attribute, otherwise an error will be reported
- Cannot use the with statement
- Prohibit this from pointing to the global object
- 12, es6 new addition
- New template string
- Arrow function
- for-of (used to traverse data—such as values in an array.)
- ES6 incorporates Promise objects into the specification and provides native Promise objects.
- Added let and const commands for declaring variables.
- There is also the introduction of the concept of module module
- 13. What is the difference between attribute and property?
- Attribute is The properties
- property that the dom element has as an html tag in the document are the properties that the dom element has as an object in js.
- For the standard attributes of html, attribute and property are synchronized and will be updated automatically
- But for custom attributes, they are not synchronized
- 14. What is the difference between let and const?
- The let command does not have variable promotion. If used before let, an error will be reported
- If there are let and const commands in the block area, a closed scope will be formed
- Repeated declarations are not allowed
- const defines a constant and cannot be modified, but if it defines an object, The data inside the object can be modified
- 15. Memory leak
- Definition: The heap memory that has been dynamically allocated in the program has not been allocated for some reason. Various problems caused by release or inability to release.
- Possible memory leaks in js: Result: slowdown, crash, large delay, etc.
- Possible causes of memory leaks in js
- Global variables
- When the dom is cleared, there are still references
- The timer is not cleared
- Memory leak caused by the existence of sub-elements
- 16. How to introduce script?
html static<script> introduction</script>
js dynamic insertion<script></script>
- ##
Hot AI Tools
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undress AI Tool
Undress images for free
Clothoff.io
AI clothes remover
AI Hentai Generator
Generate AI Hentai for free.
Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌R.E.P.O. Best Graphic Settings4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌Assassin's Creed Shadows: Seashell Riddle Solution2 weeks ago By DDDR.E.P.O. How to Fix Audio if You Can't Hear Anyone4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌R.E.P.O. Chat Commands and How to Use Them4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
CakePHP Tutorial1378
52

The article discusses useEffect in React, a hook for managing side effects like data fetching and DOM manipulation in functional components. It explains usage, common side effects, and cleanup to prevent issues like memory leaks.

Higher-order functions in JavaScript enhance code conciseness, reusability, modularity, and performance through abstraction, common patterns, and optimization techniques.

The article explains React's reconciliation algorithm, which efficiently updates the DOM by comparing Virtual DOM trees. It discusses performance benefits, optimization techniques, and impacts on user experience.Character count: 159

The article discusses currying in JavaScript, a technique transforming multi-argument functions into single-argument function sequences. It explores currying's implementation, benefits like partial application, and practical uses, enhancing code read

Article discusses connecting React components to Redux store using connect(), explaining mapStateToProps, mapDispatchToProps, and performance impacts.

The article explains useContext in React, which simplifies state management by avoiding prop drilling. It discusses benefits like centralized state and performance improvements through reduced re-renders.

Article discusses preventing default behavior in event handlers using preventDefault() method, its benefits like enhanced user experience, and potential issues like accessibility concerns.

The article discusses the advantages and disadvantages of controlled and uncontrolled components in React, focusing on aspects like predictability, performance, and use cases. It advises on factors to consider when choosing between them.
