Web Designing and Publishing

Javscript and Angular Js Question & Answer

Question :

What is JavaScript? 

Answer :

JavaScript is very powerful client side scripting language. It was developed by Brendan Eich in 1995.It is mainly used for enhancing the interaction of a user with a webpage. More interactive webpage can be designed using JavaScript. JavaScript is an object-oriented computer programming language commonly used to Create interactive effects within web browsers. It is first used by the Netscape browser, that Provides access to the HTML Document Object Model (DOM), provides access to the Browser Object Model (BOM).It allows pages to respond to events, display special effects, accept Variable text, validate data, make cookies, detect user’s browser.

Question :

What are the features of JavaScript? 

Answer :

Following are the features of JavaScript:

a. It is a lightweight, interpreted programming language.

b. It is designed for creating network-centric applications.

c. It is complementary to and integrated with Java.

d. It is an open and cross-platform scripting language. 

Question :

What is an operator and what are its types in JavaScript?

Answer :

Operators are used for comparing values, perform arithmetic operations, etc. For example, if we take a simple expression, 4+5 is equal to 9. Here 4 and 5 called operands and ‘+’ is called the operator. JavaScript consists of different types of operators that are used to Perform different operations.

Types of JavaScript Operators There are different types of operators in JavaScript that are used for performing different Operations. Some of the JavaScript Operators include:

a. Arithmetic Operators

b. Comparison Operators

c. Bitwise Operators

d. Logical Operators

e. Increment/Decrement Operator

f. Bitwise Operator

g. Assignment Operators

h. Conditional Operator

Question :

What is Angular JS expressions? Explain with example

Answer :

AngularJS expressions are those that are written inside double braces {{expression}}.AngularJS evaluates the specified expression and binds the result data to HTML. AngularJS expressions can also be written inside a directive: ng-bind="expression".

AngularJS expression can contain literals, operators and variables. AngularJS displays the data exactly at the place where the expression is placed.

For example, an expression {{6/2}} will produce the result 3 and will be bound to HTML.

 <html >
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
<body >
<h2> AngularJS Expression Example</h2>
 <div ng-app="">
<p> Addition: 6 + 2 = {{6 + 2}} </p> <br />
<p> Subtraction: 6 - 2 = {{6 - 2}} </p><br />
<p> Multiplication: 6 * 2 = {{6 * 2}} </p><br />
<p> Division: 6 / 2 = {{6 / 2}}</p>

Question :

What are Directives in Angular Js? Explain important directives.

Answer :

AngularJS directives are used to extend HTML. Directives are markers on HTML DOM element that tell AngularJS to attach a specified behavior to that HTML element.

Directives in AngularJS are special attributes starting with ng- prefix where ng stands for Angular. AngularJS includes various built-in directives, you may also create your own directive in AngularJS. Some built-in directives are listed here.


The ng-app directive defines the root element of an AngularJS application and starts an AngularJS Application.The ng-app directive will auto-bootstrap (automatically initialize) the application when a web page is loaded. It is also used to load various AngularJS modules in AngularJS Application.


ng-init directive initializes an AngularJS Application data. It is used to declare and assign values to the variables for an AngularJS application. 


The ng-repeat directive repeats HTML elements for each item in a collection. Or simply say that it is used to loop through items in collection element and it will act as for loop.


The ng-model directive is used for two-way data binding in AngularJS. It is used to get value of input controls like textbox, label, etc and use these values in web pages.


The ng-bind directive binds the model property declared via ng-model directive or the result of an expression to the HTML element. It also updates an element if the value of an expression changes. 

Question :

What is form validation in JavaScript? How client side validation is different from server level validation. 

Answer :

Whenever we are working with Forms on webpages to submit some data, the Form validations are usually occurring at the server end, i.e. as the user entered all the necessary data and press the Submit button, all the filled data are submitted to server and subsequently validated. If the data entered by the user is incorrect or simply missing, the server sends all the data back to the client and requests for resubmitting of data through form with correct information. This is really a lengthy process which used to put a lot of burden on the server.

Using JavaScript, there are ways to validate most of the form's data on the user system itself before sending it to the web server. This is called Form validation and generally performs two functions:

Basic Form Validation – In this, initially form must be checked to make sure all the mandatory fields are filled in. This is simple and requires a loop through each field in the form to check for data. For Example, Name, Mobile no. and email is mandatory. 

Data Format Validation – In this type of validation, the data entered can be checked for correct format and values (may be some value ranges). It is required that the JS code written must include appropriate logic to test correctness of data. For example, mobile no must be of 10 digits, email must be in correct format or PinCode shall be of 6 digits not starting with zero or Marks obtained shall be between 0 and 100. 

Question :

What are events? Where they are used. 

Answer :

When the user manipulates a page events may be occurred. Events are fired inside the browser window, and tend to be attached to a specific item that resides in it which may be a single element, set of elements, the HTML document loaded in the current tab, or the entire browser window. JavaScript's interaction with HTML is handled through events. Events are occurred whenever a page is loaded (page load event), the user clicks a button (button click event) or events are occurred on pressing any key, closing a window, resizing a window, etc. Some more types of events may occur on:

  • hovering the cursor over a certain element.
  • web page finishing loading.
  • A form being submitted.
  • A video being played, or paused, or finishing play.
  • An error occurring. 

The occurrence of these events may be used by the Programmers and to execute responses coded in JavaScript like cause buttons to close windows, messages to be displayed to users, data to be validated, or any other type of response.

Events are a part of the DOM (Document Object Model) Level 3 and every HTML element contains a set of events which may trigger a block of JavaScript Code written for that specific purpose, i.e. JavaScript can "react" on these events and allows executing the code when events are detected.

The most common Events are

onchange - An HTML element has been changed

onclick - The user clicks an HTML element (button, image etc)

onmouseover - The user moves the mouse over an HTML element

onmouseout - The user moves the mouse away from an HTML element

onkeydown - The user pushes a keyboard key

onload - The browser has finished loading the page  

Question :

What are AngularJS modules?

Answer :

AngularJS supports modular approach of programming. AngularJS modules are used to divide or separate the logic such as controllers, services, application etc. and keep the code clean. AngularJS module helps to link many components, so it is just a group of related components.

Generally in most of the applications we have a single entry point (main method) that instantiate and club together different parts of the application. In angularjs applications we don’t have that main method instead we have modules that specify how our application will be structured and bootstrapped.

Modules are defined in separate .js files and name them as per the module.js file, if these are kept in different file. Controllers always belong to a module.

Let us have two modules for an application, and we create them as

Application Module − used to initialize an application with controller(s). Application module is created by using the AngularJS function angular module  

Controller Module − used to define the controller. These refer to the controller with the ng-controller directive. 

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad