


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
Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!
Hot Article
What's New in Windows 11 KB5054979 & How to Fix Update Issues3 weeks ago By DDDHow to fix KB5055523 fails to install in Windows 11?2 weeks ago By DDDInZoi: How To Apply To School And University3 weeks ago By DDDHow to fix KB5055518 fails to install in Windows 10?2 weeks ago By DDDRoblox: Dead Rails – How To Summon And Defeat Nikola Tesla4 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

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

React is the preferred tool for building interactive front-end experiences. 1) React simplifies UI development through componentization and virtual DOM. 2) Components are divided into function components and class components. Function components are simpler and class components provide more life cycle methods. 3) The working principle of React relies on virtual DOM and reconciliation algorithm to improve performance. 4) State management uses useState or this.state, and life cycle methods such as componentDidMount are used for specific logic. 5) Basic usage includes creating components and managing state, and advanced usage involves custom hooks and performance optimization. 6) Common errors include improper status updates and performance issues, debugging skills include using ReactDevTools and Excellent

React components can be defined by functions or classes, encapsulating UI logic and accepting input data through props. 1) Define components: Use functions or classes to return React elements. 2) Rendering component: React calls render method or executes function component. 3) Multiplexing components: pass data through props to build a complex UI. The lifecycle approach of components allows logic to be executed at different stages, improving development efficiency and code maintainability.

The React ecosystem includes state management libraries (such as Redux), routing libraries (such as ReactRouter), UI component libraries (such as Material-UI), testing tools (such as Jest), and building tools (such as Webpack). These tools work together to help developers develop and maintain applications efficiently, improve code quality and development efficiency.

React is a JavaScript library for building user interfaces, with its core components and state management. 1) Simplify UI development through componentization and state management. 2) The working principle includes reconciliation and rendering, and optimization can be implemented through React.memo and useMemo. 3) The basic usage is to create and render components, and the advanced usage includes using Hooks and ContextAPI. 4) Common errors such as improper status update, you can use ReactDevTools to debug. 5) Performance optimization includes using React.memo, virtualization lists and CodeSplitting, and keeping code readable and maintainable is best practice.

The advantages of React are its flexibility and efficiency, which are reflected in: 1) Component-based design improves code reusability; 2) Virtual DOM technology optimizes performance, especially when handling large amounts of data updates; 3) The rich ecosystem provides a large number of third-party libraries and tools. By understanding how React works and uses examples, you can master its core concepts and best practices to build an efficient, maintainable user interface.

React is a front-end framework for building user interfaces; a back-end framework is used to build server-side applications. React provides componentized and efficient UI updates, and the backend framework provides a complete backend service solution. When choosing a technology stack, project requirements, team skills, and scalability should be considered.

React's main functions include componentized thinking, state management and virtual DOM. 1) The idea of componentization allows splitting the UI into reusable parts to improve code readability and maintainability. 2) State management manages dynamic data through state and props, and changes trigger UI updates. 3) Virtual DOM optimization performance, update the UI through the calculation of the minimum operation of DOM replica in memory.
