Web Developer Interview Questions and Answers
Ques 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.
Ques 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);
}
Ques 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.
Ques 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.
Ques 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;
}
Most helpful rated by users: