Professional Documents
Culture Documents
Top 25 front-end interview questions for web developers
Top 25 front-end interview questions for web developers
Interview Questions
for Web Developers
1. What are the differences between HTML and XHTML?
Answer: HTML is the standard markup language for creating web pages.
XHTML is a stricter and more well-defined version of HTML. It's frequently
used for formatting more complex documents within a stated taxonomy.
HTML code:
Unset
<!DOCTYPE html>
<html>
<body>
</body>
</html>
XHTML code:
Unset
7. What are some common issues that you have faced with cross-
browser compatibility?
Answer: Some of the most common issues with cross-browser compatibility
are different browsers rendering CSS differently, different browsers supporting
different HTML and CSS features, and different browsers having different
levels of support for standards. This is particularly difficult as many browsers
differ depending on the platform, and the platform differs so widely; someone
can open Chrome OS on a smart fridge today.
Unset
function functionName(name) {
this.name = name;
}
// Creating an object
var variable_name= new functionName("JTP");
console.log(variable_name.name); //JTP
Unset
button:hover {
background-color: lightgray;
}
active
This pseudo-class targets an element that is currently being activated, such
as when a user clicks on a link or button. Example use case: Changing the
color of a link when a user clicks on it.
Unset
a:active {
color: red;
}
15. What are BFC (Block Formatting Context) and how do they
work?
Answer: Block formatting context is a type of formatting context in CSS that
allows you to lay child elements based on the initial block layout rules.
The outermost element that uses the block layout establishes the initial block
layout rules. Every element laid inside the initial block will follow the same
rules. The initial block rules are outlined by the CSS Box model. Elements in a
BFC would have the same margins, borders, padding and would interact with
other blocks in the same context.
Local Storage: This data is stored on the client's computer. This data has no
expiration, however, it is limited only to string data. Local data can be accessed
using Javascript and HTML but cannot be transferred to the server end.
Although local storage data does not have an expiration date it can be cleared
by the user.
Cookies: Cookies sent back to the server-side and hence the size must be less
than 4KB. The data is sent back when a subsequent XHR request is made.
Although they are meant for server-side reading they can be accessed on the
client-side as well.
19. What are the advantages of using REST web services?
Answer: REST (Representational State Transfer) is an architectural style for
designing networked applications, particularly web services. RESTful web
services have gained popularity due to their simplicity, scalability, and
compatibility with various technologies. Here are some advantages of using
REST web services:
Simplicity and Ease of Use: REST principles are simple and intuitive,
making it easy for developers to understand and implement. Resources are
represented by URLs, and HTTP methods (GET, POST, PUT, DELETE) are
used for CRUD (Create, Read, Update, Delete) operations, which aligns
well with the HTTP protocol.
Statelessness: REST is stateless, meaning that each request from a client
to a server must contain all the information needed to understand and
process the request. This simplifies server logic and allows for easier
scaling since servers don't need to store client state.
Scalability: Stateless nature and separation of client and server concerns
make RESTful services highly scalable. New servers can be added without
the need for complex session management or shared state.
JavaScript
function synchronousTask() {
console.log("Task 1");
console.log("Task 2");
}
console.log("Start");
synchronousTask();
console.log("End");
Output:
Unset
Start
Task 1
Task 2
End
Asynchronous Functions:
Asynchronous functions, on the other hand, allow tasks to be executed
independently without blocking the program's flow. When an asynchronous
function is called, it initiates the task and immediately returns control back to
the program, allowing other tasks to proceed. Once the asynchronous task is
complete, a callback function or other mechanisms are used to handle the
result or continue processing.
Example of asynchronous code using callbacks in JavaScript:
JavaScript
function asynchronousTask(callback) {
setTimeout(function() {
console.log("Async Task");
callback();
}, 1000);
}
console.log("Start");
asynchronousTask(function() {
console.log("Callback executed");
});
console.log("End");
Unset
Start
End
Async Task
Callback executed
21. What is the difference between absolute, relative, fixed, and
static positions?
Answer: Absolute: An absolute element is positioned relative to the nearest
parent element. In case a parent element is not present it is positioned based
on the page itself and moves along with the page scroll.
Fixed: A fixed position implies that the element remains fixed to the viewport,
which means it stays in the same place even if the page is scrolled.
Static: Elements are positioned static by default, these elements are not
affected by positional attributes (Top, bottom, left, right). If an element is
positioned static it follows the normal flow of the page.
Unset
<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframes example</h2>
<p>
specify the size of the iframe using the height and width attributes:
</p>
<iframe src="https://simplilearn.com/" height="600" width="800">
</iframe>
</body>
</html>
Impure Pipes: Angular calls an impure pipe for every change detection cycle,
independent of the change in the input fields. For these pipes, it produces
multiple pipe instances. The inputs to these pipes can be changed.
All pipes are pure by default. On the other hand, the pure attribute can be
used to identify impure pipes, as demonstrated below.
Unset
@Pipe({
name: 'demopipe',
pure : true/false
})
export class DemopipePipe implements PipeTransform {
IAF's
Emerging
Become a Edtech Company
2023
Web Developer
in 6 months
Placement Assurance
Average Salary - INR 8 LPA
1 on 1 Mentorship & Career Guidance
Access to all Live Lectures
On-the-go Doubt Resolution