Sold to
venkatasureshbabub@gmail.com
Contents
Preface .................................................................................................................................................. 3
Introduction ........................................................................................................................................ 4
How to Read This Book .................................................................................................................. 5
Interview Preparation Tips............................................................................................................ 6
Common Interview Formats ........................................................................................................ 9
Part I Basics of Front End .......................................................................................................... 16
Object-Oriented Programming (OOP) in Front-End Development .............................. 17
HTML ................................................................................................................................................... 23
What is HTML and what does it stand for? ....................................................................... 23
What are the new features introduced in HTML5? ........................................................ 23
Explain the difference between <div> and <span> .................................................... 23
Explain the difference between semantic and non-semantic elements ................ 23
What is the purpose of the alt attribute in images? ..................................................... 24
Explain the difference between <script>, <script async>, and <script defer> 24
What is the purpose of the <meta> tag? ......................................................................... 24
Explain the concept of HTML5 Web Storage .................................................................... 24
What is the purpose of the <iframe> tag? ...................................................................... 24
Explain the difference between GET and POST methods in HTML forms ............. 24
What are data attributes in HTML5? ................................................................................... 25
Explain the concept of HTML5 semantic elements ........................................................ 25
What is the purpose of the <picture> element?............................................................ 25
Explain the concept of HTML5 form validation ............................................................... 25
What is the purpose of the doctype declaration? .......................................................... 25
Explain the difference between <div> and <span>? .................................................. 26
CSS ...................................................................................................................................................... 27
What is CSS and what does it stand for? ......................................................................... 27
Explain the concept of CSS specificity ............................................................................... 27
What's the difference between "resetting" and "normalizing" CSS? ...................... 27
Describe the box model in CSS? .......................................................................................... 27
What's the difference between inline, inline-block, and block? ............................... 28
Explain the concept of floats and how they work .......................................................... 28
What are pseudo-elements and pseudo-classes?.......................................................... 28
Explain the concept of CSS Grid........................................................................................... 28
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 1
Sold to
venkatasureshbabub@gmail.com
What is Flexbox and how does it work? ............................................................................ 28
What are CSS preprocessors and why are they used? ................................................ 29
Explain the concept of media queries ................................................................................ 29
What is the "z-index" property in CSS? ............................................................................ 29
Describe the difference between visibility: hidden and display: none .................. 29
What are CSS variables (custom properties)? ................................................................ 29
What is the box model in CSS? ............................................................................................ 29
Describe the difference between margin and padding? .............................................. 30
Part II JavaScript & TypeScript ............................................................................................... 32
JavaScript .......................................................................................................................................... 33
Core JavaScript concepts .................................................................................................... 33
What is JavaScript? ............................................................................................................... 38
What are the data types in JavaScript?......................................................................... 38
Difference between var, let, and const? ....................................................................... 40
What is the difference between == and === operators? ..................................... 40
What do you mean by the “===” operator? ............................................................... 41
What are the features of ES6? .......................................................................................... 41
Is JavaScript single-threaded? .......................................................................................... 42
Are ECMAScript and JavaScript related? How?........................................................... 42
Different ways to create an Object in JavaScript? .................................................... 42
What is rest and spread operator? .................................................................................. 48
What is a higher-order function? ..................................................................................... 49
What is Closure? What are the use cases of Closures? ........................................... 50
Explain the Event loop in JavaScript. ............................................................................. 52
Explain the concept of hoisting in JavaScript. ............................................................ 53
What is callback function and callback hell? ................................................................ 54
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 2
Sold to
venkatasureshbabub@gmail.com
Preface
I have been a software engineer for about 10 years. During my initial years as a
developer, I struggled with one key question: How can I better prepare for
interviews?
The resources I found online were mostly tutorials rather than insights from
actual interview experiences. This made me realize the gap between theoretical
preparation and practical exposure. So, I decided to appear in as many
interviews as possible to gain firsthand experience and understand the actual
questions being asked.
After each interview, I would document the entire transcript and focus on
improving my weak areas or unanswered questions. Over time, this habit of
journaling proved invaluable, as I accumulated detailed transcripts of over 20–
30 interviews for both front-end and back-end development roles.
This process not only helped me clear many interviews but also motivated me to
organize my notes into a structured format. It became a go-to resource for me,
allowing me to quickly review and prepare before any interview.
The idea of writing this book stems from that experience. It has been incredibly
beneficial to me, and I hope it will be equally helpful to you. Through this book, I
aim to provide valuable insights into front-end developer interview questions and
help you seize new opportunities with confidence.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 3
Sold to
venkatasureshbabub@gmail.com
Introduction
This is the book I wish I had early in my career when preparing for front-end or
full-stack developer interviews. It could have saved me countless hours of
searching for the right set of interview questions.
The book is structured to guide you from the basics of front-end development to
advanced frameworks like React and Angular. It is divided into five parts to
ensure a logical progression and comprehensive coverage.
This book is designed to be helpful for everyone—from freshers to experienced
professionals, covering a range of experience levels from 0 to 8 years. If you're
a beginner, I strongly recommend starting with the basics before diving into
advanced topics. On the other hand, experienced developers may choose to skip
foundational sections like HTML, CSS, and OOPs, and focus directly on
framework-specific interview questions, such as those for React, Angular, or
Node.js.
I hope this book offers you valuable insights into actual interview questions for
front-end developer roles and helps you succeed in your journey.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 4
Sold to
venkatasureshbabub@gmail.com
How to Read This Book
This book is composed of five standalone parts, each consisting of several
chapters, making it easy for you to navigate and focus on the topics most
relevant to your needs:
• Part I – Basics for Front-End
• Part II – JavaScript & TypeScript
• Part III – Front-End Frameworks (React, Angular, Redux, etc.)
• Part IV – Back-End Frameworks (Node.js)
• Part V – Coding Questions
Each part is designed to cater to developers at different stages of their careers,
from freshers to experienced professionals. Parts I to V are applicable to all
entry-level engineers, providing a comprehensive foundation. However, if you
are an experienced developer and already familiar with the basics like HTML,
CSS, and Object-Oriented Programming (OOPs), you may choose to skip Part I
and dive directly into advanced sections.
The book's modular design allows you to tailor your reading experience based on
your current skill set and areas of focus. If you are new to the field, start with
the basics to build a strong foundation. For those with prior experience, you can
prioritize chapters on advanced frameworks and coding challenges to refine your
expertise and prepare for more senior-level interview questions.
The JavaScript and TypeScript section (Part II) provides an in-depth
understanding of core concepts, modern practices, and advanced topics like
asynchronous programming and design patterns, which are essential for both
front-end and back-end development roles.
Parts III and IV delve into frameworks that are widely used in the industry.
Whether you're preparing for a role as a React developer or a full-stack
engineer, these sections cover the essential topics you need to know to excel in
technical interviews.
Finally, Part V focuses on coding questions, including algorithmic challenges and
problem-solving techniques that are commonly tested in interviews. These
questions are curated from real-world interview experiences and are designed to
help you improve your problem-solving skills.
Use this book as a flexible guide, referring to the sections that align with your
career stage and goals. Whether you're preparing for your first job or aiming to
level up in your career, this book is a resource to support you on your journey.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 5
Sold to
venkatasureshbabub@gmail.com
Interview Preparation Tips
Preparing for a full stack developer interview requires more than just technical
knowledge. This chapter will guide you through essential tips to help you present
your best self and increase your chances of success.
1. Research the Company
Study the company's products, services, and recent news
Understand their tech stack and development practices
Research their company culture and values
Prepare thoughtful questions about the company and the role
2. Review Your Resume
Ensure your resume is up-to-date and tailored to the job description
Be prepared to discuss any project or technology mentioned in your resume
Have specific examples ready to illustrate your skills and experiences
3. Brush Up on Core Concepts
Review fundamental concepts in front-end and back-end development
Practice explaining complex ideas in simple terms
Stay updated on current trends and best practices in full stack development
4. Enhance Your Problem-Solving Skills
Practice coding problems on platforms like LeetCode, HackerRank, or CodeWars
Focus on data structures and algorithms
Work on improving your time management during problem-solving
5. Prepare for Behavioral Questions
Use the STAR method (Situation, Task, Action, Result) to structure your answers
Prepare examples demonstrating leadership, teamwork, and problem-solving
Practice discussing challenges you've faced and how you overcame them
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 6
Sold to
venkatasureshbabub@gmail.com
6. Mock Interviews
Conduct mock interviews with friends, mentors, or using online services
Practice speaking your thoughts aloud while solving problems
Get comfortable with virtual interview tools if applicable
7. Prepare Your Development Environment
Have a clean, professional background for video interviews
Ensure your development environment is set up and ready for coding tests
Test your audio, video, and internet connection before the interview
8. Showcase Your Projects
Be ready to discuss your personal or professional projects in detail
Prepare to explain your role, challenges faced, and solutions implemented
If possible, have a portfolio website ready to showcase your work
9. Understand the Interview Process
Research common interview formats for full stack positions
Prepare for different types of interviews: technical, behavioral, system design
Be ready for pair programming or live coding sessions
10. Soft Skills Matter
Work on your communication skills
Practice active listening
Demonstrate enthusiasm and a willingness to learn
11. Technical Preparation
Review core languages: JavaScript, HTML, CSS, and any backend languages
Understand key concepts in databases, APIs, and server management
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 7
Sold to
venkatasureshbabub@gmail.com
Be familiar with version control systems, particularly Git
12. Stay Calm and Confident
Practice relaxation techniques to manage interview stress
Remember that it's okay to ask for clarification if you don't understand a
question
If you don't know something, be honest and explain how you would find the
answer
13. Follow-Up
Prepare a thank-you email to send after the interview
Use this opportunity to reiterate your interest and address any points you
missed
14. Continuous Learning
Stay curious and keep learning, even after your interview preparation
Follow industry leaders and participate in developer communities
Contribute to open-source projects to gain more experience
Remember, the goal of interview preparation is not just to pass the interview,
but to improve your skills as a developer. Each interview, regardless of the
outcome, is a learning experience that will contribute to your professional
growth.
Approach your preparation with a positive mindset, and view the interview as an
opportunity to showcase your skills and learn about exciting new opportunities.
With thorough preparation and the right attitude, you'll be well-equipped to
tackle any full stack developer interview. Good luck!
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 8
Sold to
venkatasureshbabub@gmail.com
Common Interview Formats
Understanding the various interview formats, you might encounter is crucial for
effective preparation. Front-End developer interviews often involve multiple
stages, each designed to assess different aspects of your skills and experience.
Here's an overview of common interview formats you may encounter:
1. Initial Screening
Phone or Video Screening
• Format: Usually, a 15–30-minute call with a recruiter or HR
representative
• Purpose: To verify basic qualifications and assess communication skills
• What to Expect:
o Questions about your background and experience
o Brief overview of your technical skills
o Discussion about your interest in the role and company
Online Coding Assessment
• Format: Timed online coding test, usually 1-2 hours
• Purpose: To evaluate basic coding skills and problem-solving abilities
• What to Expect:
o Algorithmic problems
o Data structure manipulation
o Basic front-end or back-end coding tasks
2. Technical Interviews
Conceptual Technical Interview
• Format: Video call or in-person interview with a technical team member
• Purpose: To assess your understanding of fundamental concepts
• What to Expect:
o Questions on programming languages (e.g., JavaScript, Python)
o Web development concepts (e.g., HTTP, REST APIs)
o Database knowledge
o System design basics
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 9
Sold to
venkatasureshbabub@gmail.com
Coding Interview
• Format: Live coding session, either remote or in-person
• Purpose: To evaluate your coding skills and problem-solving approach
• What to Expect:
o Solving algorithmic problems
o Implementing data structures
o Debugging code
o Explaining your thought process as you code
System Design Interview
• Format: Discussion and diagramming session
• Purpose: To assess your ability to design large-scale systems
• What to Expect:
o Designing a high-level architecture for a given problem
o Discussion on scalability, performance, and reliability
o Justifying design choices
Front-End Specific Interview
• Format: Combination of conceptual questions and practical tasks
• Purpose: To evaluate your front-end development skills
• What to Expect:
o HTML, CSS, and JavaScript questions
o Framework-specific questions (e.g., React, Angular, Vue)
o Browser compatibility issues
o Responsive design principles
o Possibly a take-home project
Back-End Specific Interview
• Format: Conceptual questions and possibly practical tasks
• Purpose: To assess your back-end development skills
• What to Expect:
o Server-side programming language questions
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 10
Sold to
venkatasureshbabub@gmail.com
o Database design and query optimization
o API design principles
o Server architecture and deployment questions
3. Behavioural Interview
• Format: In-person or video call with hiring manager or team lead
• Purpose: To assess your soft skills and cultural fit
• What to Expect:
o Questions about past experiences and how you handled specific
situations
o Discussions about teamwork and conflict resolution
o Questions about your career goals and motivations
4. Pair Programming Interview
• Format: Collaborative coding session with an interviewer
• Purpose: To evaluate your coding skills and ability to work with others
• What to Expect:
o Working on a shared coding environment
o Solving a problem collaboratively
o Explaining your thought process and discussing trade-offs
5. Take-Home Project
• Format: A project assignment to be completed in your own time
• Purpose: To assess your ability to deliver a complete, real-world solution
• What to Expect:
o A project specification with requirements
o Usually given 2-7 days to complete
o Follow-up discussion about your implementation choices
6. On-Site Interview (or Virtual Equivalent)
• Format: A series of interviews with various team members
• Purpose: Comprehensive evaluation of your technical skills, problem-
solving abilities, and cultural fit
• What to Expect:
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 11
Sold to
venkatasureshbabub@gmail.com
o Multiple rounds of technical interviews
o Behavioural interviews
o System design discussions
o Possibly a presentation or code review of a take-home project
Tips for Handling Different Interview Formats
1. Be prepared for any format: Companies may use any combination of
these formats, so be ready for all possibilities.
2. Practice regularly: Use online platforms to practice coding problems and
system design questions.
3. Think aloud: During problem-solving interviews, explain your thought
process clearly.
4. Ask clarifying questions: Don't hesitate to seek clarification if a
question or task is unclear.
5. Manage your time: In timed assessments, allocate your time wisely
across all questions or tasks.
6. Be honest about your knowledge: If you don't know something, say
so, but explain how you would find the answer.
7. Show enthusiasm: Regardless of the format, demonstrate your passion
for technology and learning.
Remember, each company may have its unique interview process. Always ask
your recruiter about the specific formats you'll encounter so you can prepare
adequately. Good luck with your interviews!
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 12
Sold to
venkatasureshbabub@gmail.com
How to Switch to React from Angular as a
Developer
Switching from Angular to React can be a smooth transition if you
approach it systematically. Here are some pointers and steps to help you
make the switch:
1. Understand the Core Concepts of React
While both Angular and React are used for building front-end applications,
their approaches and core concepts differ. Start by understanding the
fundamental principles of React.
• Component-Based Architecture: Like Angular, React uses
components as building blocks, but in React, components are
typically more focused on the view and can be functional or class-
based.
• JSX: React uses JSX, a syntax extension that allows you to write
HTML-like code within JavaScript. Get comfortable with writing and
reading JSX.
• State and Props: Learn how React manages state within
components (useState for functional components) and how data is
passed down through props.
• Lifecycle Methods: Understand the lifecycle of React components,
especially when using class components (componentDidMount,
componentDidUpdate, componentWillUnmount). For functional
components, learn about hooks like useEffect.
2. Explore React’s Ecosystem
React’s ecosystem includes various libraries and tools that you might use
in your projects. Familiarize yourself with some of the most commonly
used ones.
• React Router: For handling routing in your React applications.
• State Management Libraries: Redux, MobX, or the Context API for
more complex state management needs.
• Build Tools: Create React App (CRA) for bootstrapping new React
projects, or tools like Vite for faster development builds.
3. Practical Learning Resources
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 13
Sold to
venkatasureshbabub@gmail.com
Invest time in learning resources to build your foundational knowledge
and practical skills.
• Official Documentation: Start with the React documentation. It’s
comprehensive and well-organized.
• Online Courses and Tutorials: Platforms like Udemy, Coursera, and
freeCodeCamp offer courses specifically on React.
• YouTube Channels: Channels like Academind, Traversy Media, and
The Net Ninja provide excellent React tutorials.
4. Build Small Projects
Hands-on experience is invaluable. Start with small projects to practice
your skills.
• Todo List App: A simple application to manage a list of tasks, which
will help you understand state management and component
interaction.
• Weather App: An app that fetches weather data from an API,
helping you practice data fetching and displaying dynamic data.
• Blog Platform: A small blog platform where you can practice
routing, state management, and component lifecycle.
5. Transition Your Angular Knowledge to React
Leverage your existing knowledge of Angular to understand similar
concepts in React.
• Component Interaction: Similar to Angular's input/output
properties, React uses props to pass data and callbacks between
components.
• State Management: Compare Angular's services and RxJS with
React's useState, useReducer, and Context API.
• Lifecycle Methods: Map Angular’s lifecycle hooks to React’s lifecycle
methods and hooks.
6. Join React Communities
Engage with the React community to stay updated and get support.
• Online Forums: Join communities on Reddit, Stack Overflow, and
Dev.to to ask questions and share knowledge.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 14
Sold to
venkatasureshbabub@gmail.com
• Meetups and Conferences: Attend local meetups or online
conferences like React Conf to network with other React developers.
7. Study Codebases and Open-Source Projects
Examine real-world React codebases to see how experienced developers
structure and write their React applications.
• GitHub Repositories: Look at popular React repositories on GitHub
to understand best practices.
• Open-Source Projects: Contribute to open-source projects to get
hands-on experience and feedback from other developers.
8. Work on Conversion Projects
If possible, work on converting some of your existing Angular projects to
React. This can be a great way to directly compare the frameworks and
deepen your understanding of React.
Example Learning Path
1. Week 1-2: Learn React basics (components, JSX, props, state).
2. Week 3-4: Dive into React hooks and lifecycle methods.
3. Week 5-6: Explore React Router and manage routing.
4. Week 7-8: Learn state management with Context API and Redux.
5. Week 9-10: Build a complete project (e.g., a weather app or a blog
platform).
Additional Tips
• Practice Regularly: Regular practice is key to retaining new
concepts.
• Pair Programming: If possible, pair up with a React developer to
learn through collaboration.
• Stay Updated: Follow React blogs and newsletters to stay updated
with the latest trends and updates.
By following these steps and leveraging your existing Angular knowledge,
you can successfully transition to React and become proficient in this
popular front-end library.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 15
Sold to
venkatasureshbabub@gmail.com
Part I Basics of Front End
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 16
Sold to
venkatasureshbabub@gmail.com
Object-Oriented Programming
(OOP) in Front-End Development
Object-Oriented Programming (OOP) is a programming paradigm that
organizes code around objects rather than functions or logic. It focuses on
creating reusable, modular, and scalable software by encapsulating data
and behaviours into entities known as objects. While OOP principles are
traditionally associated with languages like Java, C++, and Python, they
are equally relevant in front-end development, especially with modern
JavaScript frameworks and libraries.
In this chapter, we will explore how OOP concepts apply to front-end
development, discuss key principles, and examine practical examples.
Core OOP Principles and Their Relevance to Front-End Development
1. Encapsulation
Encapsulation is the bundling of data (properties) and methods
(functions) that operate on that data into a single unit or object. This
principle ensures that internal implementation details are hidden from the
outside world, exposing only what is necessary through a public interface.
Example in Front-End:
In JavaScript, encapsulation can be achieved using classes or ES6
modules. Components in frameworks like React and Angular often
encapsulate their state and behavior, providing a clear interface for
interaction.
class Button {
constructor(label, color) {
this.label = label;
this.color = color;
render() {
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 17
Sold to
venkatasureshbabub@gmail.com
return `<button style="background-color:
${this.color}">${this.label}</button>`;
const submitButton = new Button('Submit', 'blue');
document.body.innerHTML = submitButton.render();
In this example, the Button class encapsulates the label and color
properties and exposes the render method to create a button.
2. Inheritance
Inheritance allows one class (child) to derive properties and behaviors
from another class (parent), promoting code reuse and reducing
redundancy.
• Example in Front-End: You can use inheritance to create
variations of a base component.
class Button {
constructor(label, color) {
this.label = label;
this.color = color;
render() {
return `<button style="background-color:
${this.color}">${this.label}</button>`;
class IconButton extends Button {
constructor(label, color, icon) {
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 18
Sold to
venkatasureshbabub@gmail.com
super(label, color);
this.icon = icon;
render() {
return `<button style="background-color: ${this.color}">
<i class="${this.icon}"></i> ${this.label}
</button>`;
const settingsButton = new IconButton('Settings', 'gray', 'fa fa-cog');
document.body.innerHTML = settingsButton.render();
Here, the IconButton class inherits from Button and extends its
functionality by adding an icon.
3. Polymorphism
Polymorphism enables a single interface to represent different underlying
data types or classes. This principle allows methods in different classes to
have the same name but behave differently.
• Example in Front-End: In React, polymorphism can be observed
when different components implement the same interface but with
unique behavior.
class Shape {
draw() {
throw new Error('Method draw() must be implemented.');
class Circle extends Shape {
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 19
Sold to
venkatasureshbabub@gmail.com
draw() {
return 'Drawing a Circle';
class Square extends Shape {
draw() {
return 'Drawing a Square';
const shapes = [new Circle(), new Square()];
shapes.forEach(shape => console.log(shape.draw()));
This code demonstrates polymorphism where the draw method is
implemented differently for Circle and Square classes.
4. Abstraction
Abstraction involves hiding implementation details and exposing only the
essential features of an object or system.
• Example in Front-End: Abstraction is commonly used in
component libraries where only the public API is exposed to the
user.
class APIService {
constructor(baseURL) {
this.baseURL = baseURL;
fetchData(endpoint) {
return fetch(`${this.baseURL}/${endpoint}`).then(response =>
response.json());
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 20
Sold to
venkatasureshbabub@gmail.com
}
const apiService = new APIService('https://api.example.com');
apiService.fetchData('users').then(data => console.log(data));
Here, the APIService class abstracts the complexities of making API calls,
exposing only the fetchData method to the consumer.
OOP and Modern Front-End Frameworks
Modern front-end frameworks heavily utilize OOP principles. Here’s how:
• React: React components, especially class-based ones, use OOP
principles such as encapsulation (state management) and
inheritance (Higher-Order Components).
• Angular: Angular’s services, components, and directives often
follow OOP patterns, with decorators like @Component and
@Injectable enabling encapsulation and dependency injection.
• Vue: Vue’s single-file components encapsulate templates, styles,
and logic, adhering to OOP concepts.
Advantages of OOP in Front-End Development
1. Reusability: Code written using OOP principles can be reused
across different projects or components, reducing redundancy.
2. Scalability: OOP structures make it easier to scale applications as
they grow in complexity.
3. Maintainability: Encapsulation and modular design make
debugging and updating code more manageable.
4. Readability: Code organized around objects and their interactions
is often more intuitive for developers to understand.
When to Use OOP in Front-End Development
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 21
Sold to
venkatasureshbabub@gmail.com
While OOP is powerful, it’s essential to evaluate its necessity based on the
project:
• Use OOP for large-scale applications with complex state
management and multiple components.
• For smaller projects or simple UIs, functional programming may be
more efficient.
By understanding and applying OOP principles, front-end developers can
create robust, maintainable, and scalable applications. Embracing OOP in
front-end development not only improves the quality of your code but
also prepares you to tackle real-world challenges effectively.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 22
Sold to
venkatasureshbabub@gmail.com
HTML
This chapter covers essential HTML concepts that you may be asked about in a
full stack developer interview. Each question is followed by a concise answer to
help you prepare.
What is HTML and what does it stand for?
HTML stands for HyperText Markup Language. It is the standard markup
language used for creating web pages and web applications. HTML describes the
structure of a web page semantically and originally included cues for the
appearance of the document.
What are the new features introduced in HTML5?
HTML5 introduced several new features, including:
• Semantic elements like <header>, <nav>, <article>, and <section>
• <audio> and <video> elements for media playback
• <canvas> element for 2D drawing
• <svg> element for scalable vector graphics
• Geolocation APIs
• Drag and Drop API
• Local Storage
• Form improvements (new input types and attributes)
Explain the difference between <div> and <span>
• <div> is a block-level element used for grouping larger sections of
content.
• <span> is an inline element used for grouping small portions of text or
elements within a line.What is the purpose of the DOCTYPE
declaration?
The DOCTYPE declaration tells the browser which version of HTML the page is
using. This helps the browser render the page correctly. For HTML5, the
declaration is simply <!DOCTYPE html>.
Explain the difference between semantic and non-semantic
elements
• Semantic elements clearly describe their meaning in a human- and
machine-readable way (e.g., <form>, <table>, <article>).
• Non-semantic elements don't have any inherent meaning (e.g., <div>,
<span>).
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 23
Sold to
venkatasureshbabub@gmail.com
What is the purpose of the alt attribute in images?
The alt attribute provides alternative information for an image if a user cannot
view it. It's used by screen readers to describe the image to visually impaired
users and is displayed if the image fails to load.
Explain the difference between <script>, <script async>, and
<script defer>
• <script>: HTML parsing is blocked, the script is fetched and executed
immediately.
• <script async>: The script is fetched asynchronously and executed as
soon as it's available (potentially before HTML parsing completes).
• <script defer>: The script is fetched asynchronously but executed only
after HTML parsing is complete.
What is the purpose of the <meta> tag?
The <meta> tag provides metadata about the HTML document. It can be used
to specify character encoding, page description, keywords, author, and other
metadata not covered by other HTML elements.
Explain the concept of HTML5 Web Storage
HTML5 Web Storage allows web applications to store data locally within the
user's browser. There are two types:
• localStorage: Stores data with no expiration date
• sessionStorage: Stores data for one session (data is lost when the
browser tab is closed)
What is the purpose of the <iframe> tag?
The <iframe> tag is used to embed another document within the current HTML
document. It's commonly used for embedding videos, maps, or external content
from other websites.
Explain the difference between GET and POST methods in HTML
forms
• GET: Data is appended to the URL, visible in the address bar, and has
length limitations. Suitable for non-sensitive data.
• POST: Data is included in the body of the HTTP request, not visible in the
URL, and can send large amounts of data. Suitable for sensitive
information.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 24
Sold to
venkatasureshbabub@gmail.com
What are data attributes in HTML5?
Data attributes allow you to store extra information on standard HTML elements.
They are prefixed with data- and can be accessed via JavaScript, making them
useful for storing custom data private to the page or application.
Explain the concept of HTML5 semantic elements
HTML5 semantic elements are tags that provide meaning to the structure of web
content. Examples include <header>, <nav>, <article>, <section>, <aside>,
and <footer>. They improve accessibility, SEO, and overall document structure.
What is the purpose of the <picture> element?
The <picture> element contains multiple <source> elements and one <img>
element to provide different images for different display/device scenarios. It
allows for more flexibility in specifying image resources for responsive design.
Explain the concept of HTML5 form validation
HTML5 introduced form validation features that allow browsers to natively
validate form inputs. This includes attributes like required, pattern, min, max,
and input types like email, url, and number.
Remember, in an interview, it's not just about knowing the answers, but also
about demonstrating your understanding of how and when to apply these
concepts in real-world scenarios. Be prepared to discuss practical applications
and your experiences with these HTML features.
What is the purpose of the doctype declaration?
the doctype declaration is a way of telling the browser what version of
HTML the web page is using. Depending on the version of HTML specified
in the <!DOCTYPE> declaration at the beginning of the document, the
browser knows whether to adhere to modern standards, ensuring
consistent rendering across different browsers (standards mode), or to
accommodate older, potentially inconsistent coding practices (quirks
mode).
<!DOCTYPE> declaration has numerous advantages for web
applications:
1. It ensures whether the browser renders the web page in standards
mode or quirks mode. This improves the consistency, compatibility,
and quality of the web page across different browsers and devices.
2. It enables the use of HTML5 features, such as semantic elements,
multimedia elements, form validation, accessibility, and
interactivity. This enhances the functionality and user experience of
the web application.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 25
Sold to
venkatasureshbabub@gmail.com
3. It helps to avoid errors and bugs that may occur due to invalid or
outdated HTML code, which reduces development and maintenance
costs.
4. It also improves the SEO (Search Engine Optimization) of the web
page, increasing the visibility and ranking of the web application on
search engines.
Explain the difference between <div> and <span>?
A div element is used for block-level organization and styling of page
elements, whereas a span element is used for inline organization and
styling.
<div> example:
<div id=“paragraphs”>
<p>This is my first paragraph.<p>
<p>This is my second paragraph.</p>
<p>This is my final paragraph.</p>
</div>
<span> example
<p>This is a paragraph with <span id=“special-text”>a little something
extra</span> inside it.</p>
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 26
Sold to
venkatasureshbabub@gmail.com
CSS
This chapter covers essential CSS concepts that you may be asked about in a full
stack developer interview. Each question is followed by a concise answer to help
you prepare.
What is CSS and what does it stand for?
CSS stands for Cascading Style Sheets. It's a style sheet language used for
describing the presentation of a document written in HTML or XML. CSS
describes how elements should be rendered on screen, on paper, in speech, or
on other media.
Explain the concept of CSS specificity
CSS specificity is the algorithm used by browsers to determine which CSS rule
gets applied when there are multiple rules targeting the same element. It's
calculated based on the selector's components:
Inline styles
IDs
Classes, attributes, and pseudo-classes
Elements and pseudo-elements
The more specific rule takes precedence.
What's the difference between "resetting" and "normalizing" CSS?
Resetting CSS removes all built-in browser styling. This means elements like h1-
h6, p, strong, etc. will appear exactly alike.
Normalizing CSS aims to make built-in browser styling consistent across
browsers. It preserves useful defaults rather than "unstyling" everything.
Describe the box model in CSS?
The CSS box model describes the rectangular boxes generated for elements in
the document tree and laid out according to the visual formatting model. It
consists of:
Content: The actual content of the box
Padding: Clear area around the content (inside the border)
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 27
Sold to
venkatasureshbabub@gmail.com
Border: Goes around the padding and content
Margin: Clear area outside the border
What's the difference between inline, inline-block, and block?
inline: The element doesn't start on a new line and only takes up as much width
as necessary.
inline-block: Like inline, but allows setting width and height.
block: The element starts on a new line and takes up the full width available.
Explain the concept of floats and how they work
Floats remove an element from the normal document flow and push it to the left
or right side of its containing box. Other content then flows around the floated
element. Floats are often used for layouts, though modern techniques like
Flexbox and Grid are now preferred.
What are pseudo-elements and pseudo-classes?
Pseudo-elements allow you to style a specific part of an element (e.g., ::before,
::after, ::first-line).
Pseudo-classes specify a special state of an element (e.g., :hover, :active, :first-
child).
8. What is the difference between em, rem, and px units?
px: Absolute unit, one pixel on the screen.
em: Relative to the font-size of the element (2em means 2 times the size of the
current font).
rem: Relative to the root element's font-size.
Explain the concept of CSS Grid
CSS Grid is a two-dimensional layout system that allows you to create complex
responsive web design layouts more easily and consistently across browsers. It
works by applying column and row styles to a parent element (Grid Container)
to create a grid. Child elements (Grid Items) can then be placed onto the grid.
What is Flexbox and how does it work?
Flexbox is a one-dimensional layout method for laying out items in rows or
columns. It provides a more efficient way to layout, align and distribute space
among items in a container, even when their size is unknown or dynamic. The
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 28
Sold to
venkatasureshbabub@gmail.com
main idea behind flexbox is to give the container the ability to alter its items'
width/height to best fill the available space.
What are CSS preprocessors and why are they used?
CSS preprocessors are scripting languages that extend the default capabilities of
CSS. They enable the use of variables, nested rules, mixins, functions, and other
features that make CSS more maintainable and easier to work with. Popular
preprocessors include Sass, Less, and Stylus.
Explain the concept of media queries
Media queries allow you to apply CSS styles based on the device characteristics,
like screen size, resolution, or orientation. They are a fundamental part of
responsive web design, allowing websites to adapt their layout and styling for
different devices and screen sizes.
What is the "z-index" property in CSS?
The z-index property specifies the stack order of an element (which element
should be placed in front of, or behind, others). It only works on elements with a
position value other than static.
Describe the difference between visibility: hidden and display: none
visibility: hidden: The element is hidden but still takes up space in the layout.
display: none: The element is completely removed from the document flow and
doesn't take up any space.
What are CSS variables (custom properties)?
CSS variables, also known as custom properties, are entities defined by CSS
authors that contain specific values to be reused throughout a document. They
are set using custom property notation (e.g., --main-color: black;) and are
accessed using the var() function (e.g., color: var(--main-color);).
Remember, in an interview setting, it's beneficial to not only provide the answer
but also to discuss real-world applications of these concepts and any experiences
you've had using them in projects. Be prepared to give examples and discuss
trade-offs between different approaches.
What is the box model in CSS?
The box model in CSS defines the properties and behavior of every
element on a web page. It conceptualizes each HTML element as a
rectangular box with four main components: content, padding, border,
and margin.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 29
Sold to
venkatasureshbabub@gmail.com
CSS Box model
1. Content: This is the actual content of the element, such as text,
images, or other media. It’s the innermost part of the box and is
surrounded by padding.
2. Padding: Padding is the space between the content and the border of
the element. It provides visual separation between the content and the
border, helping to control the spacing inside the box.
3. Border: The border is a line that surrounds the padding and content of
the element. It defines the boundary of the element and can be styled
with various properties like color, width, and style.
4. Margin: Margin is the space outside the border of the element. It
creates space between the element and adjacent elements. Margin is
useful for controlling the layout and spacing between elements on the
page.
The box model is very crucial for effective styling and positioning
elements on a webpage. By manipulating the properties of each
component, such as width, height, padding, border, and margin,
developers can create visually appealing and well-structured layouts.
Describe the difference between margin and padding?
same as above (point 2 for padding and point4 for margin)
Responsive Design:
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 30
Sold to
venkatasureshbabub@gmail.com
• What is the importance of media queries in responsive design?
• Describe the difference between em and rem units in CSS.
CSS Flexbox:
• What is the flexbox model, and how does it work?
• Explain the purpose of justify-content and align-items in flexbox.
CSS Grid:
• How does CSS Grid differ from Flexbox?
• Explain the use of the grid-template-columns property.
AJAX:
• What is AJAX, and how does it work?
• Explain the role of the XMLHttpRequest object.
RESTful API Concepts:
• What is REST, and how does it differ from SOAP?
• Describe the common HTTP methods used in RESTful APIs.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 31
Sold to
venkatasureshbabub@gmail.com
Part II JavaScript & TypeScript
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 32
Sold to
venkatasureshbabub@gmail.com
JavaScript
Core JavaScript concepts
This chapter covers essential JavaScript concepts that every full stack developer
should master. Understanding these core concepts is crucial for writing efficient,
maintainable, and robust JavaScript code.
1. Variables and Data Types
JavaScript has several data types:
Primitive types: number, string, boolean, null, undefined, symbol, bigint
Object type: object
Variables can be declared using var, let, or const:
let name = "John"; // string
const age = 30; // number
var isStudent = true; // boolean
const skills = ["JavaScript", "React", "Node.js"]; // array (object)
const person = { name: "John", age: 30 }; // object
Key points:
let and const have block scope, while var has function scope.
const variables cannot be reassigned, but for objects and arrays, their properties
can be modified.
2. Functions
Functions are first-class citizens in JavaScript, meaning they can be assigned to
variables, passed as arguments, and returned from other functions.
// Function declaration
function greet(name) {
return `Hello, ${name}!`;
// Arrow function
const greetArrow = (name) => `Hello, ${name}!`;
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 33
Sold to
venkatasureshbabub@gmail.com
// Function as an argument (callback)
function doOperation(x, y, operation) {
return operation(x, y);
const result = doOperation(5, 3, (a, b) => a + b);
console.log(result); // Outputs: 8
3. Scope and Closures
Scope determines the accessibility of variables. JavaScript has function scope
and block scope.
Closures are functions that have access to variables in their outer (enclosing)
lexical scope, even after the outer function has returned.
function outer() {
const message = "Hello";
function inner() {
console.log(message);
return inner;
const innerFunc = outer();
innerFunc(); // Outputs: "Hello"
4. this Keyword and Binding
The value of this depends on how a function is called:
In a method, this refers to the object the method was called on.
In a regular function, this refers to the global object (or undefined in strict
mode).
In an arrow function, this retains the value of the enclosing lexical context.
const person = {
name: "John",
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 34
Sold to
venkatasureshbabub@gmail.com
greet: function() {
console.log(`Hello, I'm ${this.name}`);
},
greetArrow: () => {
console.log(`Hello, I'm ${this.name}`); // 'this' is not bound to person
};
person.greet(); // Outputs: "Hello, I'm John"
person.greetArrow(); // Outputs: "Hello, I'm undefined"
5. Prototypes and Inheritance
JavaScript uses prototypal inheritance. Objects can inherit properties and
methods from other objects.
function Animal(name) {
this.name = name;
Animal.prototype.speak = function() {
console.log(`${this.name} makes a sound.`);
};
function Dog(name) {
Animal.call(this, name);
Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;
Dog.prototype.bark = function() {
console.log("Woof!");
};
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 35
Sold to
venkatasureshbabub@gmail.com
const dog = new Dog("Buddy");
dog.speak(); // Outputs: "Buddy makes a sound."
dog.bark(); // Outputs: "Woof!"
6. Asynchronous JavaScript
JavaScript is single-threaded, but it can handle asynchronous operations
through:
Callbacks
function fetchData(callback) {
setTimeout(() => {
callback("Data received");
}, 1000);
fetchData((data) => console.log(data));
Promises
JavaScript
Copy
function fetchData() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Data received");
}, 1000);
});
fetchData().then(data => console.log(data));
Async/Await
JavaScript
Copy
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 36
Sold to
venkatasureshbabub@gmail.com
async function getData() {
const data = await fetchData();
console.log(data);
getData();
7. ES6+ Features
Modern JavaScript (ES6 and beyond) introduced several new features:
Arrow functions
Template literals
Destructuring
Spread and rest operators
Classes
Modules
let and const
Default parameters
Map and Set
Example:
// Destructuring and arrow function
const getFullName = ({ firstName, lastName }) => `${firstName}
${lastName}`;
// Spread operator
const numbers = [1, 2, 3];
const moreNumbers = [...numbers, 4, 5];
// Class
class Person {
constructor(name) {
this.name = name;
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 37
Sold to
venkatasureshbabub@gmail.com
}
sayHello() {
console.log(`Hello, I'm ${this.name}`);
8. Event Loop and Concurrency Model
JavaScript uses an event loop to handle asynchronous operations:
All synchronous code is executed in the call stack.
Asynchronous operations (like setTimeout, AJAX calls) are delegated to the
browser APIs.
When these operations complete, their callbacks are placed in the task queue.
Once the call stack is empty, the event loop pushes the first task from the queue
to the stack.
Understanding this model is crucial for writing efficient non-blocking code.
These core concepts form the foundation of JavaScript programming. Mastering
them will greatly enhance your ability to write efficient and effective JavaScript
code, whether you're working on the front-end or back-end of a full stack
application.
What is JavaScript?
JavaScript is a client-side scripting language as well as a server-side
scripting language. This scripting language can be written into HTML
pages (also could use CSS for styling the pages), and web browsers
understand the page.
This scripting language also acts like an object-oriented programming
language but not a class-based object-oriented language.
What are the data types in JavaScript?
JavaScript is a dynamic and loosely typed, or duck-typed
language. It means that we do not need to specify the type of variable
because the JavaScript engine dynamically determines the data type of a
variable based on its values.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 38
Sold to
venkatasureshbabub@gmail.com
Primitive data types in JavaScript are the most basic data types that
represent single values. They are immutable (cannot be changed)
and directly hold a specific value.
In JavaScript, a Symbol is a primitive data type introduced in
ECMAScript 6 (ES6) that represents a unique and immutable value. It
is often used as an identifier for object properties to avoid name
collisions
const mySymbol = Symbol('key');
const obj = {
[mySymbol]: 'value'
};
When a Symbol is used as a property key, it doesn’t clash with other
property keys, including string keys.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 39
Sold to
venkatasureshbabub@gmail.com
Difference between var, let, and const?
In a browser the window object is the window of the browser, the
top structure in the HTML tree. Variables declared with var globally
are attached to the window object. Type var dog = ‘bowser’ in the
browser’s console and then type window.dog. The value ‘bowser’ appears!
This makes controlling the scope of the variable even more difficult. By
contrast, let and const are not attached to the window object.
What is the difference between == and === operators?
== (Loose Equality Operator): This operator performs type
coercion, which means it converts the operands to the same type
before making the comparison. It checks if the values are equal without
considering their data types. For example, 1 == '1' will return true
because JavaScript converts the string '1' to a number before comparison.
=== (Strict Equality Operator): This operator performs a strict
comparison without type coercion. It checks if both the values and
their data types are equal. For example, 1 === '1' will return false
because the data types are different (number and string).
In summary, == checks for equality after type coercion, whereas ===
checks for strict equality, considering both the values and their data
types.
Execution of == will be fast as compared to the === statement.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 40
Sold to
venkatasureshbabub@gmail.com
Some of the examples that covers the above cases:
0 == false // true
0 === false // false
1 == "1" // true
1 === "1" // false
null == undefined // true
null === undefined // false
'0' == false // true
'0' === false // false
[]==[] or []===[] //false, refer different objects in memory
{}=={} or {}==={} //false, refer different objects in memory
What do you mean by the “===” operator?
This operator is called a strict equality operator.
It returns true when the two operands have the same value without
having any type of conversion.
So, we could say that it is a strict equality operator which returns false
values are similar types.
What are the features of ES6?
ES6, also known as ECMAScript 2015, introduced several new features
and enhancements to JavaScript, significantly expanding the language’s
capabilities. Some key features of ES6 include:
• Arrow Functions
• Block-Scoped Variables
• Classes
• Modules
• Template Literals: Template literals allow for embedding
expressions and multi-line strings using backticks, providing a
more convenient way to create complex strings in JavaScript.
• Default Parameters
• Rest and Spread Operators
• Destructuring Assignment
• Promises
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 41
Sold to
venkatasureshbabub@gmail.com
• Map, Set, WeakMap, WeakSet: ES6 introduced new built-in
data structures, such as Map and Set, for more efficient and
specialized handling of collections and key-value pairs.
• Iterators and Generators
• Enhanced Object Literals
Is JavaScript single-threaded?
Yes, JavaScript is a single-threaded language. This means that it has
only one call stack and one memory heap. Only one set of
instructions is executed at a time.
Also, JavaScript is Synchronous and blocking in nature. meaning that
code is executed line by line and one task must be completed before the
next one begins
However, JavaScript also has asynchronous capabilities, which allow
certain operations to be executed independently of the main execution
thread. This is commonly achieved through mechanisms like callbacks,
promises, async/await, and event listeners. These asynchronous features
enable JavaScript to handle tasks such as fetching data, handling user
input, and performing I/O operations without blocking the main thread,
making it suitable for building responsive and interactive web
applications.
Are ECMAScript and JavaScript related? How?
ECMAScript is a standard for creating a scripting language. Introduced by
ECMA International and is basically an implementation with which we
learn how to create a scripting language.
JavaScript is a general-purpose scripting language that follows the
specification of ECMAScript. It is mostly an implementation which tells
how to use a scripting language.
Different ways to create an Object in JavaScript?
In JavaScript, there are several ways to create objects. Some common
methods for object creation include:
a)Object Literals: The most straightforward way to create an object is
by using object literals, which define an object’s properties and methods
in a comma-separated list enclosed in curly braces.
let person = {
firstName: 'John',
lastName: 'Doe',
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 42
Sold to
venkatasureshbabub@gmail.com
greet: function() {
return 'Hello, ' + this.firstName + ' ' + this.lastName;
};
b)Constructor Function: Constructor functions can be used to create
multiple instances of an object with the new keyword. Inside the
constructor function, properties and methods can be assigned to the this
keyword.
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.greet = function() {
return 'Hello, ' + this.firstName + ' ' + this.lastName;
};
let person1 = new Person('John', 'Doe');
let person2 = new Person('Jane', 'Smith');
c)Object.create(): The Object.create() method allows you to create a
new object with a specified prototype object. This method provides more
control over the prototype of the newly created object.
let personProto = {
greet: function() {
return 'Hello, ' + this.firstName + ' ' + this.lastName;
};
let person = Object.create(personProto);
person.firstName = 'John';
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 43
Sold to
venkatasureshbabub@gmail.com
person.lastName = 'Doe';
d)Class Syntax (ES6): With the introduction of ES6, JavaScript supports
class syntax for defining objects using the class keyword. This provides a
more familiar and structured way to create objects and define their
properties and methods.
class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
greet() {
return 'Hello, ' + this.firstName + ' ' + this.lastName;
let person = new Person('John', 'Doe');
e)Factory Functions: Factory functions are functions that return an
object. This approach allows you to encapsulate the object creation
process and easily create multiple instances with custom properties.
function createPerson(firstName, lastName) {
return {
firstName: firstName,
lastName: lastName,
greet: function() {
return 'Hello, ' + this.firstName + ' ' + this.lastName;
};
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 44
Sold to
venkatasureshbabub@gmail.com
let person1 = createPerson('John', 'Doe');
let person2 = createPerson('Jane', 'Smith');
f)Object.setPrototypeOf(): The Object.setPrototypeOf() method can be
used to set the prototype of a specified object. This offers an alternative
approach to setting the prototype of an object after its creation.
let personProto = {
greet: function() {
return 'Hello, ' + this.firstName + ' ' + this.lastName;
};
let person = {};
person.firstName = 'John';
person.lastName = 'Doe';
Object.setPrototypeOf(person, personProto);
g)Object.assign(): The Object.assign() method can be used to create a
new object by copying the values of all enumerable own properties from
one or more source objects to a target object. This is particularly useful
for merging objects or creating a shallow copy.
let target = { a: 1, b: 2 };
let source = { b: 3, c: 4 };
let mergedObject = Object.assign({}, target, source);
h)Prototype Inheritance: JavaScript uses prototypal inheritance,
allowing objects to inherit properties and methods from other objects. You
can create objects by leveraging prototypal inheritance and using the
prototype property of constructor functions or classes to define shared
behavior.
function Animal(name) {
this.name = name;
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 45
Sold to
venkatasureshbabub@gmail.com
Animal.prototype.greet = function() {
return 'Hello, I am ' + this.name;
};
function Dog(name, breed) {
Animal.call(this, name);
this.breed = breed;
Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;
let myDog = new Dog('Max', 'Poodle');
i)Singleton Pattern: The singleton pattern is used to restrict an object
to a single instance. It can be implemented in JavaScript using a
combination of closures and immediately invoked function expressions
(IIFE). This ensures that only one instance of the object is created.
let singleton = (() => {
let instance;
function createInstance() {
return {
// properties and methods
};
return {
getInstance: () => {
if (!instance) {
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 46
Sold to
venkatasureshbabub@gmail.com
instance = createInstance();
return instance;
};
})();
What are different array methods in JavaScript?
Adding/Removing Elements:
• push(): Adds one or more elements to the end of an array
• pop(): Removes the last element from an array
• unshift(): Adds one or more elements to the beginning of an array
• shift(): Removes the first element from an array
• splice(): Changes the contents of an array by removing or replacing
existing elements and/or adding new elements
Searching and Accessing:
• indexOf(): Returns the first index at which a given element can be
found
• lastIndexOf(): Returns the last index at which a given element can
be found
• find(): Returns the first element in the array that satisfies a
provided testing function
• findIndex(): Returns the index of the first element in the array that
satisfies a provided testing function
• includes(): Determines whether an array includes a certain value
Transforming:
• map(): Creates a new array with the results of calling a provided
function on every element
• filter(): Creates a new array with all elements that pass the test
implemented by the provided function
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 47
Sold to
venkatasureshbabub@gmail.com
• reduce(): Executes a reducer function on each element of the array,
resulting in a single output value
• flatMap(): Maps each element using a mapping function, then
flattens the result into a new array
Iterating:
• forEach(): Executes a provided function once for each array element
• every(): Tests whether all elements in the array pass the test
implemented by the provided function
• some(): Tests whether at least one element in the array passes the
test implemented by the provided function
Sorting and Reversing:
• sort(): Sorts the elements of an array in place and returns the
sorted array
• reverse(): Reverses the order of the elements in an array in place
Other Useful Methods:
• concat(): Merges two or more arrays
• slice(): Returns a shallow copy of a portion of an array
• join(): Joins all elements of an array into a string
• flat(): Creates a new array with all sub-array elements
concatenated into it recursively up to the specified depth
ES2022+ Methods:
• at(): Takes an integer value and returns the item at that index,
allowing for negative integers
What is rest and spread operator?
The rest operator, represented by three dots (...), is used in function
parameters to collect a variable number of arguments into an
array. It allows you to pass an arbitrary number of arguments to a
function without explicitly defining them as named parameters.
function sum(...numbers) {
return numbers.reduce((total, num) => total + num, 0);
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 48
Sold to
venkatasureshbabub@gmail.com
}
console.log(sum(1, 2, 3, 4)); // Outputs 10
The spread operator, also denoted by three dots (...), is used to
spread the elements of an array or object into another array or
object. It allows you to easily clone arrays, concatenate arrays, and
merge objects.
const array1 = [1, 2, 3];
const array2 = [4, 5, 6];
const mergedArray = [...array1, ...array2];
// mergedArray is [1, 2, 3, 4, 5, 6]
const obj1 = { a: 1, b: 2 };
const obj2 = { b: 3, c: 4 };
const mergedObject = { ...obj1, ...obj2 };
// mergedObject is { a: 1, b: 3, c: 4 }
What is a higher-order function?
Higher-order function in JavaScript is a function that either takes one
or more functions as arguments or returns a function as its result.
In other words, it operates on functions, either by taking them as
arguments, returning them, or both.
function operationOnArray(arr, operation) {
let result = [];
for (let element of arr) {
result.push(operation(element));
return result;
function double(x) {
return x * 2;
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 49
Sold to
venkatasureshbabub@gmail.com
let numbers = [1, 2, 3, 4];
let doubledNumbers = operationOnArray(numbers, double);
console.log(doubledNumbers); // Output: [2, 4, 6, 8]
They enable powerful techniques such as function composition, currying,
and callback-based asynchronous operations. Understanding higher-order
functions is essential for writing expressive and functional-style JavaScript
code.
A unary function (i.e. monadic) is a function that accepts exactly
one argument. It stands for a single argument accepted by a function.
What is Closure? What are the use cases of Closures?
Closure is a feature that allows the function to capture the environment
(or to retain access to variables from the scope ) where it is defined,
even after that scope has closed.
We can say the closure is a combination of a function and lexical
environment where that function is defined.
In other words, a closure gives a function access to its own scope, the
scope of its outer function, and the global scope, allowing it to
“remember” and continue to access variables and parameters from these
scopes.
function outerFunction() {
let outerVariable = 'I am from the outer function';
return innerFunction() {
console.log(outerVariable); // Accessing outerVariable from the outer
function's scope
let myFunction = outerFunction();
myFunction(); // Output: I am from the outer function
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 50
Sold to
venkatasureshbabub@gmail.com
Closure is created every time when a function is created at the
time of function creation and when you define a function inside
another function.
Execution context is an environment where JavaScript code is executed.
For each function call a separate execution context is created and pushed
into the execution stack. Once function execution completed it is popped
off from stack.
Every execution context has a space in memory where its variables and
function are stored, and once the function popped off from the execution
stack a JavaScript Garbage collector clear all of these things.
In JavaScript, anything is garbage-collected only when there are no
references to it.
In the above example, the anonymous execution context still has a
reference to the variables to the memory space of its outer environment.
Even though the outerFunction() is finished. (It can access the
outerVariable variable and use it inside console.log(outerVariable)).
Closures have several important use cases in JavaScript:
• Data Privacy and Encapsulation: Closures can be used to create
private data and encapsulate functionality within a limited scope. By
defining functions within another function, the inner functions have
access to the outer function’s variables, but these variables are
inaccessible from outside the outer function. This allows for the
creation of private data and methods that are not directly accessible
from the outside, thereby enhancing data privacy and
encapsulation.
• Maintaining State: Closures are often used to maintain state in
asynchronous operations and event handling. For example, when
handling asynchronous tasks, closures can capture and retain the
state of variables across multiple asynchronous operations, ensuring
that the correct variables are accessed when the asynchronous
tasks complete.
• Currying and Partial Application: Closures facilitate functional
programming techniques such as currying and partial application.
By using closures to capture and remember specific parameters and
return a new function that uses these captured parameters,
currying and partial application can be achieved. This allows for the
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 51
Sold to
venkatasureshbabub@gmail.com
creation of specialized functions with pre-set arguments, providing
flexibility and reusability.
• Module Pattern: Closures are essential in implementing the
module pattern in JavaScript. By using closures to create private
variables and expose only the necessary public methods, developers
can create modular and organized code, preventing unwanted
access and modification of internal module data.
• Callback Functions: Closures are often employed when working
with callback functions. A closure can be used to capture and
maintain the state of variables within the context of an
asynchronous operation, ensuring that the correct variables are
accessible when the callback function is invoked.
Explain the Event loop in JavaScript.
The Event loop is a core component of the JavaScript runtime
environment. It is responsible for scheduling and executing
asynchronous tasks. The event loop works by continuously monitoring
two queues: the call stack and the event queue.
The call stack is a stack(LIFO) data structure that stores the
functions that are currently being executed (stores the execution
context created during the code execution).
Web APIs is the place where the async operations (setTimeout, fetch
requests, promises) with their callbacks are waiting to complete. It
borrows the thread from the thread pool to complete the task in
the backgroundwithout blocking the main thread.
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 52
Sold to
venkatasureshbabub@gmail.com
The job queue (or microtasks) is a FIFO (First In, First Out) structure
that holds the callbacks of async/await, promises,
process.nextTick() that are ready to be executed. For example, the
resolve or reject callbacks of a fulfilled promise are enqueued in the job
queue.
The task queue (or macrostasks) is a FIFO (First In, First Out)
structure that holds the callbacks of async operations (timer like
setInterval, setTimeout)that are ready to be executed. For example,
the callback of a timed-out setTimeout() — ready to be executed — is
enqueued in the task queue.
The Event loop permanently monitors whether the call stack is
empty. If the call stack is empty, the event loop looks into the job queue
or task queue and dequeues any callback ready to be executed into
the call stack.
Explain the concept of hoisting in JavaScript.
Hoisting in JavaScript is the default behavior where variable and
function declarations are moved to the top of their containing
scope during the compilation phase, before the actual code
execution. This means that you can use a variable or call a function
before it’s declared in your code.
When you declare a variable using var, the declaration is hoisted to the
top of its containing function or block and initialized with the default
value of “undefined”.
console.log(x); // Outputs: undefined
var x = 5;
Variables declared with let and const are hoisted as well but have a
"temporal dead zone" where they cannot be accessed before their
declaration.
console.log(x); // Throws an error (ReferenceError)
let x = 5;
Function declarations are also hoisted to the top of their containing scope.
You can call a function before it’s declared in your code.
sayHello(); // Outputs: "Hello, world!"
function sayHello() {
console.log("Hello, world!");
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 53
Sold to
venkatasureshbabub@gmail.com
}
Hoisting is not happening with an arrow function, function
expression, or variable initialization.
What is callback function and callback hell?
In JavaScript, callbacks are commonly used to handle asynchronous
operations.
Callback function is a function that is passed as an argument to
another function and is intended to be executed after the completion
of a specific task or at a given time.
function fetchData(url, callback) {
// Simulate fetching data from a server
setTimeout(() => {
const data = 'Some data from the server';
callback(data);
}, 1000);
function processData(data) {
console.log('Processing data:', data);
fetchData('https://example.com/data', processData);
In this example, the fetchData function takes a URL and a callback
function as arguments. After fetching the data from the server
(simulated using setTimeout), it calls the callback function and passes the
retrieved data to it.
Callback Hell, also known as “Pyramid of Doom” is a term used in
JavaScript programming to describe a situation where multiple nested
callbacks are used within asynchronous functions.
“It occurs when asynchronous operations depend on the results of
previous asynchronous operations, resulting in deeply nested and
often hard-to-read code.”
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 54
Sold to
venkatasureshbabub@gmail.com
Callback Hell is an anti-pattern with multiple nested callbacks which
makes code hard to read and debug when dealing with asynchronous
logic.
fs.readFile('file1.txt', 'utf8', function (err, data) {
if (err) {
console.error(err);
} else {
fs.readFile('file2.txt', 'utf8', function (err, data) {
if (err) {
console.error(err);
} else {
fs.readFile('file3.txt', 'utf8', function (err, data) {
if (err) {
console.error(err);
} else {
// Continue with more nested callbacks...
});
});
});
In this example, we’re reading three files sequentially using the
fs.readFilefunction, and each file reading operation is asynchronous. As a
result, we have to nest the callbacks inside one another, creating a
pyramid structure of callbacks.
To avoid Callback Hell, modern JavaScript provides alternatives
like Promises and async/await. Here’s the same code using Promises:
const readFile = (file) => {
return new Promise((resolve, reject) => {
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 55
Sold to
venkatasureshbabub@gmail.com
fs.readFile(file, 'utf8', (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
});
});
};
readFile('file1.txt')
.then((data1) => {
return readFile('file2.txt');
})
.then((data2) => {
return readFile('file3.txt');
})
.then((data3) => {
// Continue with more promise-based code...
})
.catch((err) => {
console.error(err);
});
Thanks For Reading Folks,
If you are Interested in Buying this book here is the link
https://rathodajay10.gumroad.com/l/njcsj
GUIDE TO CLEAR FRONT-END DEVELOPER INTERVIEW 56
Sold to
venkatasureshbabub@gmail.com