This post collects short Angular and JavaScript questions that commonly appear in frontend interviews. Each answer is intentionally concise, but includes enough context to explain the idea clearly.

Table of Contents

How can we reduce the loading time of an application?

Application loading time improves when the browser downloads, parses, and runs less unnecessary code. The goal is to send only what the first screen needs and delay everything else until it is required.

Useful techniques include:

  • Remove unused widgets, libraries, images, and CSS.
  • Minify JavaScript and CSS so the files are smaller.
  • Compress images and serve modern image formats where possible.
  • Reduce redirects because each redirect adds another network request.
  • Use lazy loading for routes, modules, images, and below-the-fold content.
  • Cache static files such as CSS, JavaScript, fonts, and images.
  • Split large bundles so the first page does not load the whole application.

For Angular applications, lazy loading feature modules is one of the most common improvements because it prevents the initial bundle from becoming too large.

What is Angular?

Angular is a free, open-source web application framework developed by Google. It is built with TypeScript and is used to create single-page applications, dashboards, admin panels, ecommerce storefronts, and other large frontend applications.

Angular provides many built-in features:

  • Components for building user interface sections.
  • Services for sharing data and business logic.
  • Dependency injection for managing reusable classes.
  • Routing for page navigation.
  • Forms support for template-driven and reactive forms.
  • HTTP tools for calling APIs.

In simple words, Angular helps developers build structured frontend applications using TypeScript, HTML, and CSS.

What is the difference between Angular and AngularJS?

AngularJS is the older framework based on JavaScript and MVC-style architecture. Angular is the modern framework based on TypeScript and component-driven architecture.

AngularJS Angular
Uses JavaScript Uses TypeScript
Follows MVC architecture Follows a component-based UI approach
Uses controllers and scopes Uses components and services
Designed for older single-page applications Designed for modern, scalable frontend applications
Lower performance compared to Angular Better performance because of modern tooling and architecture

Angular is not just a small update to AngularJS. It is a complete rewrite with a different architecture.

Is it possible to write a multiline string in JavaScript?

Yes. The best modern way is to use template literals with backticks.

js
const message = `Hello Vinay,
Welcome to the JavaScript guide.
This string can continue on multiple lines.`;

console.log(message);

You can also create multiline strings by joining multiple strings with the + operator, but template literals are cleaner and easier to read.

js
const message =
    "Hello Vinay, " +
    "welcome to the JavaScript guide. " +
    "This is written across multiple lines in the code.";

How can we get the checked status of a checkbox?

Use the checked property of the checkbox element. It returns true when the checkbox is selected and false when it is not selected.

<input type="checkbox" id="terms" />
js
const checkbox = document.getElementById("terms");

console.log(checkbox.checked);

A common mistake is reading the value property instead of checked. The value property usually returns the checkbox value attribute, not whether the checkbox is selected.

What are escape() and unescape() in JavaScript?

escape() and unescape() were older JavaScript functions used to encode and decode strings. They are now deprecated, so avoid using them in new code.

Use these modern alternatives instead:

  • encodeURIComponent() when encoding a value for a URL parameter.
  • decodeURIComponent() when decoding a URL parameter value.
  • encodeURI() when encoding a full URL.
  • decodeURI() when decoding a full URL.

Example:

js
const search = "Angular interview questions";
const encoded = encodeURIComponent(search);

console.log(encoded); // Angular%20interview%20questions
console.log(decodeURIComponent(encoded)); // Angular interview questions

What is the role of break and continue in JavaScript?

break and continue are used inside loops, but they behave differently.

break stops the loop completely:

js
for (let i = 1; i <= 5; i++) {
    if (i === 3) {
        break;
    }

    console.log(i);
}

Output:

text
1
2

continue skips the current iteration and moves to the next one:

js
for (let i = 1; i <= 5; i++) {
    if (i === 3) {
        continue;
    }

    console.log(i);
}

Output:

text
1
2
4
5

Use break when you no longer need the loop. Use continue when you only want to skip one case.

Why are Boolean operators used in JavaScript?

Boolean operators are used to compare values and make decisions. They usually return true or false, and those values are commonly used in if conditions.

Common Boolean and comparison operators include:

  • && means AND.
  • || means OR.
  • ! means NOT.
  • === checks strict equality.
  • !== checks strict inequality.

Example:

js
const isLoggedIn = true;
const hasPermission = false;

if (isLoggedIn && hasPermission) {
    console.log("Show admin dashboard");
} else {
    console.log("Access denied");
}

Boolean logic is important in Angular templates too. For example, *ngIf="isLoggedIn" displays a section only when the value is true.

Handwritten notes

Download JavaScript notes