Front-end interview basic question bank - 4

Table of contents

31. AJAX principles and applications in JavaScript.

32. Browser Same Origin Policy and its restrictions. 

33. Modular development and its role in JavaScript.

34. Media queries and their functions in CSS.

35. Recursion and its applications in JavaScript.

37. Router in React and its functions.

 38. Event Loop mechanism in JavaScript.

39. The difference between computed properties (Computed) and listeners (Watch) in Vue and their usage scenarios.

40. Promise (promise) and its functions in JavaScript.


31.   AJAX principles and applications in JavaScript.  

         AJAX (Asynchronous JavaScript and XML) in JavaScript is a technology used to create asynchronous requests and process service responses. Sending data to the server and receiving data from the server are performed asynchronously and will not interfere with the normal operation of the page. The principle of AJAX is based on the XMLHttpRequest object, which can be developed using libraries such as native JavaScript or jQuery. It is widely used in front-end web development and can be used to implement functions such as dynamic web pages and data interaction.

32. Browser Same Origin Policy   and its   restrictions.  

        The browser origin policy is a browser security policy that protects user information from being obtained by malicious websites and restricts interactive operations such as scripts, documents, and requests from different sources (protocols, domain names, ports). The restrictions of the same origin policy include not being able to read cookies from non-original websites, not being able to send AJAX requests to non-original websites, not being able to access the DOM tree of non-original websites, etc.

33. Modular development and its role in JavaScript.

        Modular development in JavaScript is a method of separating code into smaller, more manageable chunks into independent modules while avoiding issues like global variable pollution and naming conflicts. There are many ways to implement modular development in JavaScript, including AMD, CommonJS and ES6 modules.

34.   Media queries and their functions in CSS.

        Media queries in CSS are a way to apply different styles on different media devices or screen sizes. By using the @media rule, media queries can specify one or more conditions, and when they are met, the following style content will be applied. The functions of media queries include adapting to different devices, improving page responsiveness, optimizing user experience, etc.

35.   Recursion and its applications in JavaScript.

        Recursion in JavaScript is the act of calling itself within a function and can be used to process data or operations with a recursive structure. Applications of recursion include processing complex mathematical calculations, solving complex problems (such as data search, traversal, sorting, etc.) and processing complex data structures. Issues that require attention to recursion include stack overflow, recursion stop conditions, recursion depth, etc.

36.   How HTTPS works. 

         HTTPS is a security protocol based on encrypted communication and is used to secure network communications.

         The working principle of HTTPS can be divided into the following steps:

                First, the client initiates an SSL connection request to the server;

                Then, the server sends the SSL certificate to the client, and the client verifies the validity of the certificate;

                Then, the client randomly generates a key for a symmetric encryption algorithm, encrypts it using the public key and sends it to the server; the server uses the private key to decrypt and obtain the key, and uses the key to encrypt the data and sends it to the client;

                Finally, the client uses the key to decrypt the data and perform data verification.

37. Router in React and its functions .  

        Router in React is a library used to handle routing. It can display different components and content based on the URL, providing a SPA (Single Page Application) experience. 

        Router in React includes BrowserRouter, HashRouter, MemoryRouter and other components, which can implement different routing methods and operations.

 38. Event Loop mechanism in JavaScript   .   

         The event loop mechanism in JavaScript is an asynchronous programming model used to handle asynchronously executed tasks such as events and callback functions. The event loop mechanism is implemented based on the event loop queue, including macro tasks and micro tasks. It implements asynchronous processing tasks by continuously removing tasks from the queue and executing them in sequence.

39. The difference between computed properties ( Computed) and listeners ( Watch) in Vue and their usage scenarios.       

         Both computed properties and listeners in Vue can be used to monitor data changes, but the difference between the two is that computed properties return calculated values, and listeners perform a logical operation. Computed attributes are suitable for processing scenarios where certain data requires calculation to be obtained, such as price discounts, data filtering, etc.; listeners are suitable for processing scenarios where additional logic needs to be executed after data changes, such as data requests, complex operations, etc.

40. Promise (promise) and its functions in JavaScript .   

         CSS Flexbox layout (also known as Flex layout) is a CSS3 feature used to achieve flexible and responsive layout. It can realize various complex layouts and is suitable for all terminal devices and screen sizes. 

        Flexbox can realize the layout relationship between elements by defining the properties of containers and sub-elements. Flexbox introduces the following concepts:

        ● Flex container: The parent element that wraps the Flex element and is used to define the layout of the Flex element.

        ● Flex element: A sub-element of the Flex container, used to define the size, position and other attributes of the Flex element.

        ● Main Axis: Defines the main direction of the Flex container.

        ● Cross Axis: The axis perpendicular to the main axis, used to align elements on the main axis.

        Using Flex layout, you can define a Flex container by setting display: flex to achieve flexible layout and responsive design between elements.

Guess you like

Origin blog.csdn.net/qq_17189095/article/details/131828117