Web Developer 面试题与答案
问题 16. Explain the concept of CORS (Cross-Origin Resource Sharing).
CORS is a security feature implemented by web browsers to restrict web pages from making requests to a different domain than the one that served the web page.
问题 17. What is the purpose of the 'async' and 'await' keywords in JavaScript?
The 'async' keyword is used to declare an asynchronous function, and 'await' is used to pause the execution of the function until the Promise is settled.
Example:
async function fetchData() {
let response = await fetch('https://api.example.com/data');
let data = await response.json();
console.log(data);
}
问题 18. How does the 'localStorage' differ from 'sessionStorage' in HTML5?
'localStorage' persists even when the browser is closed and reopened, while 'sessionStorage' data is only available for the duration of the page session.
问题 19. What is the difference between 'GET' and 'POST' HTTP methods?
'GET' is used to request data from a specified resource, while 'POST' is used to submit data to be processed to a specified resource.
问题 20. Explain the purpose of the 'box-sizing' property in CSS.
The 'box-sizing' property defines how the width and height of an element are calculated, including the padding and border, or excluding them.
Example:
div {
box-sizing: border-box;
}
用户评价最有帮助的内容: