Frontend Developer Interview Questions and Answers
Ques 16. What is responsive web design?
Responsive web design is an approach that makes web pages render well on a variety of devices and window or screen sizes. It uses flexible grids and layouts, along with media queries.
Example:
```css
@media only screen and (max-width: 600px) {
body {
font-size: 14px;
}
}```
Ques 17. Explain the difference between `==` and `===` in JavaScript.
`==` is the equality operator that performs type coercion, while `===` is the strict equality operator that checks both value and type without coercion.
Example:
```javascript
console.log(5 == '5'); // true
console.log(5 === '5'); // false
```
Ques 18. What is the purpose of the 'defer' attribute in a script tag?
The 'defer' attribute in a script tag tells the browser to execute the script after the HTML is completely parsed, but before firing the DOMContentLoaded event.
Example:
```html
```
Ques 19. How does CSS specificity work?
Specificity is a set of rules that determines which style declarations are applied to an element. It is based on the importance, specificity, and source order of CSS rules.
Example:
```css
#id-selector {
color: red; /* higher specificity */
}
.class-selector {
color: blue;
}
```
Ques 20. What is the purpose of the 'async' and 'defer' attributes in a script tag?
'async' loads the script asynchronously, allowing it to execute while the page continues parsing. 'defer' loads the script asynchronously but ensures it executes in order after HTML parsing.
Example:
```html
```
Most helpful rated by users: