Posts

Express and Node JS Interview Questions

What is Node JS?

Node Js is one of the most popular and powerful server technologies today. It allows you to built the entire website only in one programming Language i.e Javascript. Node js is free and open-source server technology that uses Javascript to create complete web software. It runs on various platforms like Windows, Linux, Unix, Mac OS X, etc.

Quick Questions About Node JS
Node Js is written InC, C++, JavaScript Programming Language
Node Js is aOpen Source server Technology for creating mobile APIs and web apps.
Node Js is developed ByRyan Dahl
Node Js SupportsLinux, macOS, Microsoft Windows, SmartOS, FreeBSD, OpenBSD, IBM AIX Operating Systems
Node Js DependenciesV8, libuv, http-parser, c-ares, OpenSSL, zlib, Tools, npm, gyp, gtest
Node Js LicenceMIT License
Node Js Current Stable release10.16.0

Below are the list of Best Node JS Interview Questions with Express and Answers

Question 1. What is Node js ?

Node Js is one of the most popular and powerful server technologies today.
It allows you built the entire website only in one programming Language i.e Javascript. Node js is free and open source server technology that uses Javascript to create complete web software.It runs on various platforms like Windows, Linux, Unix, Mac OS X, etc.

Question 2. Explain CLI in Node.js?

CLI stands for Command Line Interface. It is a utility or program on your computer where users type commands to perform some action or run some script rather than clicking on the screen.
There are different types of command line interfaces depending on which operating system you are using. We have listed some of them below.

  • Bash on Linux.
  • Terminal of Mac.
  • Command Prompt or Powershell on Windows
  • Shell/ Command line/terminal on Unix and Ubuntu

Question 3. In which Language Node Js is written ?

Node js is written in C, C++,JavaScript.It uses Google’s open source V8 Javascript Engine to convert Javascript code to C++.

Question 4. Who is the author of Node Js ?

Node Js is written by Ryan Dahl.

Question 5. Explain What is a Javascript Engine ?

A Javascript Engine is a program that converts code written in Javascript to something that computer processor understands.

Question 6. Explain V8 Engine ?

V8 is Google’s open source high-performance JavaScript engine, written in C++ and used in Google Chrome, the open source browser from Google, and in Node.js, among others. It implements ECMAScript as specified in ECMA-262, and runs on Windows 7 or later, macOS 10.5+, and Linux systems that use IA-32, ARM, or MIPS processors. V8 can run standalone or can be embedded into any C++ application.
Source: https://developers.google.com/v8/

Question 7. Explain ECMAScript ?

ECMAScript is the standard on which Javascript is based on. It was created to standardize Javascript. It is commonly used for client-side scripting on the World Wide Web and used by Node Js for writing server applications and services.

Question 8. How can you check the installed version of Node Js ?

Use node -v command to check the installed version of Node Js.

Question 9. Explain What is NPM ?

NPM stands for node package manager. It is default Package Manager for JavaScript programming language. NPM is used for installing/updating packages and modules of Javascript.

Question 10. Explain Modules in Node Js ?

Modules are reusable block of code whose existence does not impact other code in any way. It is not supported by Javascript. Modules are introduced in ES6. Modules are important for Maintainability, Reusability, and Namespacing of Code.

Question 11. What are CommonJs Modules ?

CommonJS Modules is the Standard how to code modules are structured. It specifies an ecosystem for JavaScript outside on the server or for native desktop applications.

Question 12. For what require() is used in Node Js ?

require() is used to include modules from external files in Node Js. It is the easiest way to include a module in Node. Basically require is a function that takes a string parameter which contains the location of the file that you want to include. It reads the entire javascript file, executes the file, and then proceeds to return the exports object.
Syntax:

require('path');

Question 13. Explain module.exports in Node Js ?

The method or variable defined in modules cannot be directly accessible by the outer world, that means you cannot call a module member from the external file. In order to access module member, we need to export the functions or variables of modules using module.exports method.

Syntax and usage:

// greet.js
var greet=function(){
console.log("hello World");
}
module.exports=greet;

//In app.js

var greet=require('./greet.js');

greet();

Question 14. Is Node Js Single-threaded ?

Yes, Node Js is single threaded to perform asynchronous processing. Doing async processing on a single thread could provide more performance and scalability under typical web loads than the typical thread-based implementation.

Question 15. What are events ?

An event is an action or occurrence recognized by software/app that is handled by event handler by writing a code that will be executed when the event fired.
Mouse move, Click, file copied or deleted are some examples of events.
In Node Js there are two types of events.
1)System Events: The event that comes from the C++ side.
2)Custom Events: Custom events are user-defined events.

Question 16. Explain event loop in Node Js ?

In Node Js processes are single threaded, to supports concurrency it uses events and callbacks. An event loop is a mechanism that allows Node.js to perform non-blocking I/O operations.

Question 17. How to create a simple server in Node js that returns Hello World ?

By writing following line of code, you can create a server in Node Js.

var http =require('http');
http.createServer(function(req,res){

res.writeHead(200,{'Content-Type':'text/plain'});
res.end('Hello World\n');

}).listen(1320,'127.0.0.3');

Question 18. Difference between cluster and child_process modules?

Question 19. How to stop master process without suspending all of its child processes?

Question 20. What does emitter do and what is dispatcher?

Question 21. Since node is a single threaded process, how to make use of all CPUs?

Question 22. List some features of Express JS.

Some of the main features of Express JS are listed below: –

  • It is used for setting up middlewares so as to provide a response to the HTTP or RESTful requests.
  • With the help of express JS, the routing table can be defined for performing various HTTP operations.
  • It is also used for dynamically rendering HTML pages which are based on passing arguments to the templates.
  • It provides each and every feature which is provided by core Node JS.
  • The performance of Express JS is adequate due to the presence of a thin layer prepared by the Express JS.
  • It is used for organizing the web applications into the MVC architecture.
  • Everything from routes to rendering view and performing HTTP requests can be managed by Express JS.

Question 23. Write the steps for setting up an Express JS application.

Following are the steps used to set up an express JS application: –

  1. A folder with the same name as the project name is created.
  2. A file named package.json is created inside the folder created.
  3. “npm install” command is run on the command prompt. It installs all the libraries present in package.json.
  4. A file named server.js is created.
  5. “Router” file is created inside the package which consists of a folder named index.js.
  6. “App” is created inside the package which has the index.html file.

This way, an express JS application is set up.

Question 24. What do you mean by Express JS?

Express JS is an application framework which is light-weighted node JS. A number of flexible, useful and important features are provided by this JavaScript framework for the development of mobile as well as web applications with the help of node JS.

Question 25. Name the type of web applications which can be built using Express JS.

Single-page, multi-page, and hybrid web applications can be built using Express JS.

Question 26. What is the use of Express JS?

Express.js is a lightweight web application which helps in organizing the web application into MVC architecture on the server side.

Question 27. What function are arguments available to Express JS route handlers?

The arguments which are available to an Express JS route handler-function are-

  • Req – the request object
  • Res – the response object
  • Next (optional) – a function which is used to pass control to one of the subsequent route handlers.

The third argument is optional and may be omitted, but in some cases, it is useful where there is a chain of handlers and control can be passed to one of the subsequent route handlers skipping the current one.

Question 28. How to config properties in Express JS?

In Express JS, there are two ways for configuring the properties:

  • With process.ENV:
  • A file with the name “.env” is to be created inside the project folder.
  • All the properties are to be added in the “.env” file.
  • Any of the properties can be used in server.js.
  • With require JS:
  • A file with the name “config.json” is to be created in the config folder inside the project folder.
  • The config properties are to be added in the config.json file.
  • Now, require should be used to access the config.json file.

Question 29. How can models be defined in Express JS?

There is no notion of any database in Express JS. So, the concept of models is left up to third-party node modules, allowing the users to interface with nearly any type of database.

Question 30. How to authenticate users in express JS?

Since authentication is an opinionated area which is not ventured by express JS, therefore any authentication scheme can be used in express JS for the authentication of users.

Question 31. Which template engine is supported by express JS?

Express JS supports any template engine that conforms to the (path, locals, callback) signature.

Question 32. How can plain HTML be rendered in express JS?

There’s no need to render HTML with the res.render () function. If there’s a specific file, then you should use the res.sendFile () function. If any assets are being served from a dictionary, then express.static () middleware function needs to be used.

Question 33. Why to use Express.js?

Below are the few reasons why to use Express with Node.js

  • Express js is built on top of Node.js. It is the perfect framework for ultra-fast Input / Output.
  • Cross Platform
  • Support MVC Design pattern
  • Support of NoSQL databases out of the box.
  • Multiple templating engine support i.e. Jade or EJS which reduces the amount of HTML code you have to write for a page.
  • Support Middleware, basic web-server creation, and easy routing tools.

Question 34. Explain the difference between readFile and createReadStream in Node js ?

  • readFile load the whole file which you had marked to read whereas createReadStream reads the complete file in the parts of the size you have declared.
  • The client will receive the data faster in the case of createReadStream in contrast with readFile.
  • In readFile, a file will first completely read by memory and then transfers to a client but in later option, a file will be read by memory in a part which is sent to clients and the process continue until all the parts finish.

Question 35. List types of Http requests?

Http defines a set of request methods to perform the desired actions. These request methods are:

  1. GET: The GET method asked for the representation of the specifies resource. This request used to retrieve the data.
  2. POST: The POST technique is utilized to present an element to the predetermined resource, generally causing a change in state or reactions on the server.
  3. HEAD: The HEAD method is similar to the GET method but asks for the response without the response body.
  4. PUT: This method is used to substitute all current representations with the payload.
  5. DELETE: It is used to delete the predetermined resource.
  6. CONNECT: This request is used to settle the TCP/IP tunnel to the server by the target resource
  7. OPTION: This method is used to give back the HTTP strategies to communicate with the target resource.
  8. TRACE: This method echoes the message which tells the customer how much progressions have been made by an intermediate server.
  9. PATCH: The PATCH method gives partial modifications to a resource.

Question 36. What is difference between put and patch?

The main difference between the put and the patch is

PutPatch
The embedded entity is believed to the modified version of the resources that are deposited on the original server. It is requested to the client to replace the stored is substituted.In this, the information regarding the way of modifying the original server which has the resources to produce a new version is found.
At the time of updating the resource, you need to forward full payload as the request.At the time of updating the resource, you only need to send the parameter of the resource which you want to update.

Question 37. How can you set default node version using nvm?

Run below command on the terminal to set default node version along multiple installed versions of node. You can list all install versions of the node by running nvm ls

nvm alias default v7.3.0

Question 38. How to generate unique UUIDs/ guid in Node Js

Use node-uuid package to generate unique UUIDs/ guid in Node Js. Below code demonstrates how to generate it.

var uuid = require('node-uuid');

// Generate a v1 (time-based) id 
uuid.v1(); 

// Generate a v4 (random) id 
uuid.v4(); 

Question 39. Write a simple code to enable CORS in Node js?

CORS stands for Cross-Origin Resource Sharing. It a is a mechanism that uses additional HTTP headers to tell a browser to let a web application running at one origin (domain) have permission to access selected resources from a server at a different origin.

Use below code to enable CORS on NodeJS

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});

Question 40. List the types of application you can build using Node Js ?

Using Node Js you can build applications like:

  • Internet of Things
  • Real-Time Chats Applications
  • Complex Single-Page Applications
  • Real-Time Collaboration Tools
  • Streaming apps
  • Microservices / API’s

Question 41. Explain what is libuv in Node Js ?

libuv is Cross-platform I/O abstraction library that supports asynchronous I/O based on event loops.It is written in C and released under MIT Licence.

libuv support Windows IOCP, epoll(4), kqueue(2), and Solaris event ports. Initially, it was designed for Node.js but later it is also used by other software projects.

Reference : https://en.wikipedia.org/wiki/Libuv

Question 42. Why Zlib is used in Node js ?

Zlib is Cross-platform data compression library. It was written by Jean-loup Gailly and Mark Adler. In Node js, you can Zlib for Threadpool, HTTP requests, and responses compression and Memory Usage Tuning. In order to use zlib in node js, you need to install node-zlib package. After installation below is sample code to use Zlib.

var Buffer = require('buffer').Buffer;
var zlib = require('zlib');

var input = new Buffer('lorem ipsum dolor sit amet');
var compressed = zlib.deflate(input);
var output = zlib.inflate(compressed);

Further Reading https://nodejs.org/api/zlib.html

https://en.wikipedia.org/wiki/Zlib

Question 43. Write a program to Print 0 to N element in pyramid shape?

Question 44. List out some new features introduced in ES6?

Following are the list of few new Features introduced in ES6

  • const and let keywords
  • Array helper functions like map, forEach, filter, find, every, some, reduce
  • Arrow functions
  • Classes and enhanced object literals
  • Template strings
  • Default function arguments
  • Rest and spread operators
  • Promises
  • Modules
  • Multi-line Strings
  • Destructuring Assignment

Question 45. What is JIT and how is it related to Node JS ?

JIT stands for Just-in-time. A JIT compiler is a program which is used to send bytecode (it consists of instruction that can be interpreted) to the processor by converting it into instruction. After you have done with writing a program, the compiler compiles the source language statements into bytecode instead of compiling it into the code that carries the information which is similar to the specific hardware platform’s processor.

Relation of JIT with Node: Virtual machine of Nodejs has JIT compilation which improves the execution speed of the code. The virtual machine takes the source code and converts to machine code in runtime. By this, the hot functions which are called very often are compiled to machine code and, hence increasing speed.

Question 46. How to use aggregation in Mongoose?

Aggregations are a set of functions that are used to manipulate the data that has been returned from a MongoDB query. In Mongoose, aggregations work as a pipeline. The aggregate function accepts the array of data transformations which are applied by data using different methods in terms of arguments.

Syntax: db.customers.aggregate([ … aggregation steps go here …]);

In above, aggregation is applied to data of customers.

Question 47. How Node js read the content of a file?

Normally NodeJs reads the content of a file in non-blocking, asynchronous way. Node Js uses its fs core API to deal with files. The easiest way to read the entire content of a file in nodeJs is with fs.readFile method. Below is sample code to read a file in NodeJs asynchronously and synchronously.

Reading a file in node asynchronously/ non-blocking

var fs = require('fs'); 
fs.readFile('DATA', 'utf8', function(err, contents) {
    console.log(contents);
});
console.log('after calling readFile');

Reading a file in node asynchronously/blocking

var fs = require('fs'); 
var contents = fs.readFileSync('DATA', 'utf8');
console.log(contents);

Question 48. How Promises are better than callbacks?

Question 49. Describe Node.js event loop and event driver architecture?

Question 50. What are Streams? List types of streams available in Node Js ?

Streams are special types of objects in Node that allow us to read data from a source or write data to a destination continuously. There are 4 types of streams available in Node Js, they are

  • Readable − For reading operation.
  • Writable − For writing operation.
  • Duplex − Used for both read and write operation.
  • Transform − A type of duplex stream where the output is computed based on the input.

Further reading: https://www.tutorialspoint.com/nodejs/nodejs_streams.htm

Question 51. What is difference between return and callback in JavaScript functions?

Question 52. How does Promise and Queue work?

Question 53. What’s the first argument passed to a Node Js callback handler?

In Node Js all core modules, as well as most of the community-published modules, follows a pattern where the first argument to any callback handler is an error object. this object is optional, if there is no error then in that case null or undefined is passed to the callback.

Example of the callback function

function callback(err, results) {
	// usually we'll check for the error before handling results
	if(err) {
		// handle error somehow and return
	}
		// no error, perform standard callback handling
}

Question 54. What do you understand by middleware? How can you use middleware in Node Js?

Question 55. Explain the difference between process.tick() and setImmediate() ?

Question 56. What is the revealing module pattern?

Revealing module pattern is similar to Module Pattern.IT ExposES only the properties and methods you want via an returned Object.

var greeting = 'Hello world'
function greet() {
 console.log(greeting)
}
module.exports = {
  greet: greet
}

Question 57. what is Closures?

A Closure is a function defined within another scope that has access to all the variables within the outer scope.

Global variables can be made local (private) with closures.

Got a Questions? Share with us

Ajax Interview Questions

Question 1) Brief about Ajax.
Question 2) Differentiate between Synchronous and Asynchronous Ajax requests.
Question 3) List some advantages and disadvantages of using Ajax.
Question 4) What are different readyState in Ajax.
Question 5) What is XMLHttpRequest object in Ajax? How can you XMLHttpRequest Object?
Question 6) How to cancel the current request in Ajax?
Question 7) How to send an Ajax request in JavaScript?
Question 8) Explain Fetch API in JavaScript.
Question 9) Explain limitations of Ajax.
Question 10) Explain what is polling in AJAX.

What is AJAX

AJAX or Asynchronous Javascript and XML is one of the most preferred platforms used by developers. We also find its application in several industries and verticals as it offers unique features. A lot of brands hire developers who can work on this platform so that they can get their websites designed on it. The platform seems promising as it can build interactive web applications, which are required for retaining the visiting customer and engaging them for a longer duration. This is one of the factors that increases the page ranking on SERP. Today the demand for the AJAX developers has increased and corporate houses and business owners are looking forward to hiring them. Almost every organization is trying to hold up a strong social presence and therefore developers are hired to make the presence even stronger among the potential customers. The interview for the developers can be tough as the competition is really high and the market is full of talent. While some prefer general knowledge of programming other interviewers can ask technical questions. Thus, here is a list of compiled possibly Ajax interview questions that can be asked by an interviewer:

Below are the list of Best Ajax Interview Questions and Answers

Question 1) Brief about Ajax.

Ajax is considered to be a developer’s best friend because it offers several benefits to him such as updating the web page without reloading the entire page, requesting data from the server and also sending data to the server. AJAX is the acronym for Asynchronous JavaScript and XML. It is a new technique to communicate to and from a server/ database without completely refreshing the page. It creates faster, interactive, better web applications with help of CSS, XML, HTML, and JavaScript.

Question 2) Differentiate between Synchronous and Asynchronous Ajax requests.

Synchronous Ajax requests: In this, the script stops and waits for the server to reply before continuing. In the web application world, one has to happen after the other, i.e. the interaction between the customer and the server is synchronous. Synchronous is not recommended as it blocks/hangs the page until the response is received from the server.

Asynchronous Ajax requests handle the reply as and when it comes and allows the page to continue to be processed. Under Asynchronous, if there is any problem in the request it can be modified and recovered. The request doesn’t block the client as the browser is responsive. The user can perform other operations as well.

Question 3) List some advantages and disadvantages of using Ajax.

Ajax is a very easy concept if one has a sound knowledge of JavaScript. It uses JavaScript functions to call methods from a web service. It has certain advantages-

  • Speed– Ajax reduces the server traffic and also the time consumption on the server and client side.
  • Ajax is very responsive and fast, data can be transferred at a time.
  • XMLHttpRequest plays a significant role in Ajax. It is a special JavaScript object that calls asynchronous HTTP request to the server for transferring data.
  • One of the biggest advantages of using Ajax as forms are common elements in the web page. Ajax gives options for validation and much more.
  • One doesn’t have to completely reload the page.

There are some disadvantages attached to Ajax. They are-

  • Search engines would not be able to index Ajax applications so Ajax maybe a mistake.
  • Anyone can have access to the code of Ajax and can view source it.
  • ActiveX requests are enabled only in internet explorer and other new browsers.

Question 4) What are different readyState in Ajax.

There are total 5 ready state in Ajax:

ValueStateDescription
0UNSETClient has been created. Open() not yet called.
1OPENEDOpen() called.
2HEADRERS_RECIEVEDSend() called and headers are available.
3LOADINGDownloading: responseText holds partial data.
4DONEThe operation is complete.

Question 5) What is XMLHttpRequest object in Ajax? How can you XMLHttpRequest Object?

The XMLHttpRequest objects are used to exchange data with a server. It is an API whose methods transfer between a web browser and a web server. In XHR, it’s not necessary that data have to be in form of XML. It can be JSON or HTML. XHR can be used with protocols other than HTTP.

XMLHttpRequest is any developers kit because it has the option to update the page without reloading the entire page. You can request data from the server and also send data to the server in the background.

Question 6) How to cancel the current request in Ajax?

Current request in AJAX is cancelled when the user performs an action which sets of an Ajax request. This can be depicted with the help of auto-complete functionality for a search box where users can be helped with related search terms based on their current input, by making an AJAX request each time they pass a key in search field. The user types faster than the Ajax request and you would want to abort any non-finished requests, before starting the next one.

Question 7) How to send an Ajax request in JavaScript?

HTTP Requests are created with the help of XMLHttpRequest objects. It facilitates the transfer of data between client and server which happens via request and response. In XMLHttpRequest, you can perform the same function plus you can grab data from URL without having to refresh the page. AJAX lets you perform actions without reloading the entire page. The following steps tell how to call AJAX-

  • Create an XMLHttpRequest object.
  • Open the request with open method.
  • Now, send the request with the send method.

var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "get_results.php", true);
  xhttp.send();

Question 8) Explain Fetch API in JavaScript.

Fetch API uses to request and response objects that can be used in future whenever needed. It provides an interface for fetching resources. Fetch API uses promises that enable cleaner API. Cache API or other similar things handles the request and responses that might require you to generate your own responses programmatically.

Thus, you can now crack your interview and work as a developer in one of your dream companies by preparing from these set of question and answers to be technically sound.

Question 9) Explain limitations of Ajax.

1) Browser Integration

The dynamically created page does not register itself with the browser history engine, so triggering the “Back” function of the users’ browser might not bring the desired result.

2) Response-time Concerns

Network latency – or the interval between the user request and server response – need to be considered carefully during Ajax development.

3) Search Engine Optimization (SEO)

Websites that use Ajax to load data which should be indexed by search engines must be careful to provide equivalent Sitemaps data at a public, linked URL that the search engine can read, as search engines do not generally execute the JavaScript code required for Ajax functionality.

4) Reliance on JavaScript

Ajax relies on JavaScript, which is often implemented differently by different browsers or versions of a particular browser. Because of this, sites that use JavaScript may need to be tested in multiple browsers to check for compatibility issues.

Question 10) Explain what is polling in AJAX.

The Process of retrieving data from a server to obtain near-live data regularly is called AJAX polling.

Got a Questions? Share with us

Aurelia Interview Questions

Question 1) Explain Aurelia ?

Aurelia is a JavaScript-based client framework for the web, mobile, and desktop that leverages simple conventions to empower your creativity.

Find Top Aurelia interview questions and answers from below

Below are the list of Best Aurelia Interview Questions and Answers

Question 1) Explain Aurelia ?

Aurelia is a JavaScript based client framework for web, mobile and desktop that leverages simple conventions to empower your creativity.

Got a Questions? Share with us

Backbone js Interview Questions

Question 1) Explain what is Backbonejs?
Question 2) List Dependencies of using BackboneJs?
Question 3) What is the use of BackboneJS route?
Question 4) What is a collection in Backbone.js?
Question 5) What are the main BackboneJs native components?
Question 6) Explain Events in BackboneJs?
Question 7) What is the difference between the properties “id” and “cid” on a model object in Backbone Js?
Question 8) List out configuration options available in Backbone Js?
Question 9) What is Modelbinder in Backbone Js ?
Question 10) What is a converter in Backbone Js ?
Question 11) Explain Architecture of Backbone?
Question 12) What is Backbone.sync is used for?
Question 13) Explain what is ModelBinder in Backbone.js?
Question 14) How to access a models data from a view in Backbone.js?
Question 15) How are models attributes stored in Backbone.js?
Question 16) What is Router in Backbone? How do you create a Router with Backbone?
Question 17) What is Collection in Backbone?
Question 18) How to Create a Model In Backbone js?

Top Backbone js interview questions and Answers for freshers and experienced.

Below are the list of top 18 Backbone js interview questions. Here You can read interview questions on Backbone js.

Below are the list of Best Backbone js Interview Questions and Answers

Question 1) Explain what is Backbonejs?

Backbone.js is a client-side (Model, View, Controller) MVC-based JavaScript framework. It purely is written in Javascript.

Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

Question 2) List Dependencies of using BackboneJs?

Backbone’s Js only hard dependency is Underscore.js ( >= 1.8.3). For RESTful persistence and DOM manipulation with Backbone. View, include jQuery ( >= 1.11.0), and json2.js for older Internet Explorer support. (Mimics of the Underscore and jQuery APIs, such as Lodash and Zepto, will also tend to work, with varying degrees of compatibility.)

Question 3) What is the use of BackboneJS route?

The Backbone.js router is used to change the URL fragment or hashes of an application to create bookmarkable and shareable URLs.

Question 4) What is a collection in Backbone.js?

In Backbone.js, the collection is used to represent ordered set of models. Any event in model triggers an event in collection directly. For example, you can bind “change” event to be notified in a case when any model in the collection has been modified.

Question 5) What are the main BackboneJs native components?

The main native components of BackboneJs are:-

  • Model
  • View
  • Collection
  • Router
  • Event class object

Question 6) Explain Events in BackboneJs?

Backbone events is a module that can be mixed into any object, giving the object the ability to bind and trigger custom named events. Events are not declared before they are bound to any object. Events reflect the state of the model.

Question 7) What is the difference between the properties “id” and “cid” on a model object in Backbone Js?

The “id” property on a model is automatically assigned based on the “id” set in the model’s attributes hash.

Ideally, this is the ID that you receive from the rest API for the resource that you are querying. On the other hand, “cid” is an ID temporarily assigned to each model and is useful until an actual ID is determined for the object. For example, a model pushed to a collection that has not yet been persisted can be addressed using “cid”, until it is saved in the database and an actual ID is generated for it.

Question 8) List out configuration options available in Backbone Js?

  • InitialCopyDirection
  • modelSetOptions
  • change Triggers
  • boundAttribute
  • suppressThrows
  • converter

Question 9) What is Modelbinder in Backbone Js ?

ModelBinder class is used to make synchronization process of views and models together.

Question 10) What is a converter in Backbone Js ?

When a model’s attribute is copied to an HTML element or when an HTML element’s value is copied into a model’s attribute, a function is called, this function is known as a converter in Backbone Js.

Question 11) Explain Architecture of Backbone?

Question 12) What is Backbone.sync is used for?

Backbone.sync is a function that is Backbone js call every time it attempts to read or save a model to the server.By default, it uses jQuery.ajax to make a RESTful JSON request and returns a jqXHR

Example Code

Backbone.sync = function(method, model) {
  alert(method + ": " + JSON.stringify(model));
  model.set('id', 1);
};

var author= new Backbone.Model({
  author: "Sharad",
  website: "https://www.onlineinterviewquestions.com"
});

author.save();

author.save({author: "Teddy"});

Question 13) Explain what is ModelBinder in Backbone.js?

ModelBinder is a class in Backbone.js to bind backbone model attributes to:

  • Read-only html elements such as <span>, <div> etc.
  • Html element attributes such as enabled, displayed, style etc.
  • Editable form elements such as <input>, <textarea> etc. This type of binding is bidirectional between the HTML elements and the Model’s attributes.

Question 14) How to access a models data from a view in Backbone.js?

In order to access a models data from a view in backbone.js you have to initialize your Model :

var author= Backbone.Model.extend({
      initialize: function(){
        console.log('intailized');
      },
      defaults:{
          names:['Bob','Sim','Dart']
      }
    })
var person_view = Backbone.View.extend({
    initialize: function() {
        this.model = new author();
    },
    output: function(){
        console.log(this.model.get('names'))
    }
});

Question 15) How are models attributes stored in Backbone.js?

In Backbone.js models attributes stored in a hash.

Question 16) What is Router in Backbone? How do you create a Router with Backbone?

Backbone Router is used for routing client-side applications and connects them to actions and events using URLs. Backbone.Router is used to create a Router with Backbone.

Question 17) What is Collection in Backbone?

A collection is a set of models which binds events when the model has been modified in the collection. The collection contains a list of models that can be processed in the loop and supports sorting and filtering. When creating a collection, we can define what type of model that collection is going to have along with the instance of properties. Any event triggered on a model, which will also trigger on the collection in the model.

Question 18) How to Create a Model In Backbone js?

Creating a Model in Backbone Js

Person = Backbone.Model.extend({
initialize: function(){
alert("Welcome to Backbone Js");
}
});

var person = new Person;
Got a Questions? Share with us

D3.js interview questions

Question 1) Define D3.js?
Question 2) What does D3 stand for?
Question 3) Who developed D3.js?
Question 4) Why use to D3.js?
Question 5) How D3.js identify on which elements to operate?
Question 6) Explain selections in D3.js ?
Question 7) Explain, what is the use of “Enter” and “Exit” selection in D3.js ?
Question 8) List Type of sliders are available in D3.js?
Question 9) Explain transition in D3.js?
Question 10) List the command to interpolate two objects in D3.js?
Question 11) which is the correct way to use XML file for d3?
Question 12) What is the best way to create the stacked chart in d3 js?
Question 13) How to import XML data using d3.js?
Question 14) Which is not a valid scale in d3 js?
Question 15) What is different between d3.scale.linear() and d3.scaleLinear().
Question 16) How to alter zoom modes in d3 js?
Question 17) How to set initial zoom level in D3.js?
Question 18) How to resize an SVG when the window is resized in d3.js?
Question 19) How to get Mouse position in D3.js?
Question 20) What is the difference between canvas and SVG in d3.js?
Question 21) How to format the date in d3.js?
Question 22) List types of loops available in D3.js with syntax?
Question 23) Explain axes in D3.js?How to create d3.js axes without numbering?
Question 24) Explain Transition is D3.js?
Question 25) How to calculate the area of the polygon in d3.js?

D3.js is defined as a JavaScript-based library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation.

Data visualization Interview Questions and answers.

Question 1) Define D3.js?D3.js is defined as a JavaScript-based library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation.

Question 2) What does D3 stand for?

D3 stands for Data-Driven Documents

Question 3) Who developed D3.js?

Mike Bostock wrote D3.js based on his work during his Ph.D. studies at the Stanford Visualization Group. Mike worked at the The New York Times for a while and is now independently working on D3.js.

Question 4) Why use to D3.js?

You can use D3 js because

  • D3.js lets you to build the data visualization framework
  • D3.js focuses on binding data to DOM elements.
  • D3.js is written in JavaScript and uses a functional style which means you can reuse code and add specific functions to your heart’s content.

Question 5) How D3.js identify on which elements to operate?

D3.js uses CSS-style selectors to identify elements on which to operate.
Example:

d3.selectAll("p").style("color", "white");

Question 6) Explain selections in D3.js ?

D3 implements a declarative approach, operating on arbitrary sets of nodes called selections.
Also, Read Neo4j interview questions

Question 7) Explain, what is the use of “Enter” and “Exit” selection in D3.js ?

In D3.js “Enter” selection is used to create new nodes for incoming data and “Exit” selection is used eliminate outgoing nodes that are no longer required.

Question 8) List Type of sliders are available in D3.js?

There are 7 types of slider are available in D3.js, they are

  • Default slider
  • Slider with start value
  • Slider with slide event: 0
  • Slider with default axis
  • Slider with custom axis
  • Slider with min, max and step values
  • Vertical slider

Question 9) Explain transition in D3.js?

A transition is a selection-like interface for animating changes to the DOM. Instead of applying changes instantaneously, transitions smoothly interpolate the DOM from its current state to the desired target state over a given duration.

To apply a transition, select elements, call selection.transition and then make the desired changes.

For example:

d3.select("body")
  .transition()
    .style("background-color", "red");

Question 10) List the command to interpolate two objects in D3.js?

d3.interpolateObject(a,b) command is used to interpolate two objects in d3.js

Got a Questions? Share with us

ES8 Interview Questions

Question 1) Explain ECMAScript 2017?
Question 2) List some new features of ECMAScript 2017 or ES8?

Below are the list of Best Ecmascript 2017 Interview Questions and Answers

Question 1) Explain ECMAScript 2017?

ECMAScript 2017 is the eighth edition of the ECMAScript Language Specification released on June 2017.

Question 2) List some new features of ECMAScript 2017 or ES8?Following are some features of ECMAScript 2017

  • Async Functions
  • Shared memory and atomics
  • Object.values/Object.entries
  • String padding
  • Object.getOwnPropertyDescriptors()
  • Trailing commas in function parameter lists and calls.
Got a Questions? Share with us

Emberjs Interview questions

Question 1) What is Ember.js? Write the steps to create an app in Ember.js?
Question 2) Explain directory structure in Ember.js?
Question 3) Explain what is ember-data?
Question 4) What is ember route? How can you generate a route in ember.js?
Question 5) Write command to start and stop development server in Ember.js?
Question 6) What are observers in Ember.js?
Question 7) What is the component in ember.js? How is it defined?
Question 8) What are enumerable in ember.js?
Question 9) Explain model with reference to ember.js. Also, tell how it is defined in it.
Question 10) What are services in ember.js?
Question 11) Which template library is used by Ember.js ?
Question 12) Write steps to write a Handlebars Helper?
Question 13) How to disable Prototype Extensions in Ember.js ?

Here are a few Ember js Questions provided with their answers, which you may encounter while being interviewed and will help you crack the interview on Ember Js

Read Best Ember.js Interview Questions and Answers for Freshers and Experienced.

Below are the list of Best Emberjs Interview questions and Answers

Question 1) What is Ember.js? Write the steps to create an app in Ember.js?Ember.js is an open source technology written in javascript based on a model view pattern and was developed by ember core team on 8th December 2011. These are the steps to create an application in ember.js is :

  1. Firstly install an ember-cli. Almost all applications are built with ember-cli.
  2. Create a new application by using ember new and an application will be generated.
  3. Use materialize-CSS for styling to give a material design.
  4. Create components by using ember g component.
  5. Check whether there is a router.js file in which all of your routes are defined.
  6. If I have a video route and I would like to display a set of youtube videos on the page then I am going to create a simple video card component that I will be iterating over and display on the video page.

Question 2) Explain directory structure in Ember.js?

The new command generates a project structure also called directory structure with the following files and directories:

I-app:- This is where folders and files for models, components, routes, templates, and styles are stored.

I-bower_components/ bower.json:- Bower is a dependency management tool which is used in Ember CLI to manage front-end plugins and component dependencies.

I-config:- The config directory contains the environment.js where we can configure settings for your app.

I-dist:-When we build our app for deployment, the output files will be created here.

I-node_nodules/package.json:- Directory and files are from npm. Npm is the package manager for node.js.

Public:- This directory contains assets such as image and fonts.

Vendor:- This directory is where front-end dependencies that are not managed by Bower go.

Tests/testem.js:- Automated tests for our app go in the test folder, and testem is configured in testem.js.

Tmp:- Ember CLI temporary files live here.

Ember-cli-build.js:- This file describes how Ember CLI should build our app.

Question 3) Explain what is ember-data?

Ember comes with a data management library called Ember data which deals with application data that defines the structure of the data. We can generate ember-data model using Ember CLI. The main purpose of an ember-data is that it is a library that integrates tightly with ember.js to make it easy to retrieve records from a server, cache them for performance, save updates back to the server and create new records on the client.

Question 4) What is ember route? How can you generate a route in ember.js?

An ember route is built with three parts:

  1. An entry in the Ember router which maps between our route name and a specific URI.
  2. A route handler file, which sets up what should happen when that route is loaded.
  3. A route template, which is where we display the actual content for the page.

In ember when we want to make a new page that can be visited using a URL, we need to generate a “route” using Ember CLI. Hence the generator will print out:

  1. Installing route
  2. Create app/routes/about.hbs
  3. Create app/templates/about.hbs
  4. Updating router
  5. Add route about
  6. Installing route test

To define a route, run ember generate route route-name. This command will generate a file name route-name.js in app/routes/ folder.

Question 5) Write command to start and stop development server in Ember.js?

We can install Ember with a single command using npm such as: -npm install –g ember-cli@2.17. We can use ember new command to create a new application:- ember new ember-quickstart. This command will create a new directory called ember-quickstart and set up a new Ember application inside it. Outside, the application will include a development server. We can start a development server by typing the command:

  1. Cd ember-quickstart
  2. Ember serve

To stop the development server at any time simply type Ctrl-c in our terminal.

Question 6) What are observers in Ember.js?

Ember supports observing any property which also includes computed properties. Observers are something which contains the behavior that reacts to the changes made in other properties. Observers are used when we need to perform some behavior after a binding has finished synchronizing. New ember developers often use observers. Observers are mostly used within the ember framework and for that; computed properties are the appropriate solution. An observer can be set on an object using the following syntax- “ember.observer” Observers in ember are synchronous. They will fire as soon as they observe a change in of the properties. And, because of this, it is easy to introduce bugs where properties are not yet synchronized.

Question 7) What is the component in ember.js? How is it defined?

A component is something which encapsulates certain snippets of handlebars templates that are to be used again and again. In such case, a JavaScript is not necessary to be written. Just define the entire handlebars template and use the component that is created. Components make it easy to reuse the code, create widgets, tags in or not in the W3C, and much more. Components in ember.js are basically versions of web components.

Defining a component in Ember.js: Ember generate component component_name;

Question 8) What are enumerable in ember.js?

An enumerable is any object in ember.js which contains a number of child objects and allows us to work with those children using “ember.enumerable” API. The native JavaScript array is the most common enumerable in a majority of applications, which ember.js extends to conform to the enumerable interface. Ember.js provides us with a standardized interface for dealing with the enumerable and allows us to completely change the way our underlying data is stored without modifying the other parts of the application which accesses it. This API follows ECMAScript specifications as much as possible which hence minimizes the incompatibility with other libraries. It also allows ember.js to use the native browser implementations in arrays where they are available.

Question 9) Explain model with reference to ember.js. Also, tell how it is defined in it.

Models are objects that represent the underlying data which is presented to the user by your application. Different applications have different objects or models, and it depends completely on what problem they are trying to solve. For example, a photo album is a collection of many photos i.e. group of photos. And, a photo sharing application has a photo model to represent a particular photo. Models are persistent and most of them are loaded from and saved to a server that uses the database to store data. Once the models are loaded from the storage, the components translate the data into the user interface with which the user can interact. Defining model in ember.js: –

Syntax-

ember generate model model_name;

Question 10) What are services in ember.js?

It is a long-lived Ember object that can be made available in different parts of your application. It is created using the following syntax- “ember.service”

Example uses of Ember.js services include:

  • Logging
  • User/session authentication
  • Geolocation
  • Third-party API’s
  • Web Sockets
  • Server sent events or notifications
  • Server-backed API calls that may not fit ember-data.

Services are generated with the help of ember CLI’s service generator. If you want to access a service, inject it either in an initializer or use the following syntax- “ember.inject”. Using this you can even access the properties and methods using services. Use the following syntax to define a service:

Syntax-

ember generate service service_name;

Question 11) Which template library is used by Ember.js ?

Question 12) Write steps to write a Handlebars Helper?

Question 13) How to disable Prototype Extensions in Ember.js ?

Got a Questions? Share with us

ES6 Interview Questions

Question 1) What is ES6?
Question 2) List some new features of ES6
Question 3) What is Babel?
Question 4) List steps to install Babel?
Question 5) What is Webpack?
Question 6) List benefits of using Webpack?
Question 7) Explain Constants in Es6?
Question 8) What are template literals in Es6?
Question 9) What is Spread Operator in ES6?
Question 10) Explain Destructuring Assignment in ES6?
Question 11) How to create a Javascript class in ES6?
Question 12) What is the use of let & const in JavaScript?
Question 13) What is Set in ES6?
Question 14) Explain Generator function in ES6?
Question 15) Explain WeakMap in ES6?

What is ECMAScript 6?

ECMAScript 6 or ES6 also known as ECMAScript 2015 is the 6th edition of the ECMAScript Language Specification standard released in June 2015. Javascript and JScript of Microsoft are based on ECMAScript.The latest version of ECMAScript is ES7.

Below are the list of Best ES6 Interview Questions and Answers

Question 1) What is ES6?

Es6 or ECMASCRIPT 2015 is sixth major release of ECMAScript language which comes with a lot of new features and syntax for writing web applications in Javascript. As currently, not all browsers support ES6, they support pre-versions of ES6. So to write web applications in ES6 that will support all Browsers we needed tools like Babel and Webpack.

Question 2) List some new features of ES6

New Features in ES6.

  1. Support for constants (also known as “immutable variables”)
  2. Block-Scope support for both variables, constants, functions
  3. Arrow Functions
  4. Extended Parameter Handling
  5. Template Literals
  6. Extended Literals
  7. Enhanced Regular Expression
  8. Enhanced Object Properties
  9. Destructuring Assignment
  10. Modules, Classes, Iterators, Generators
  11. Support for Map/Set & WeakMap/WeakSet
  12. Promises, Meta-Programming ,Internationalization & Localization

Read More from http://es6-features.org

Question 3) What is Babel?

Babel is one of the most popular JavaScript transpilers and becomes the industry standard. It allows us to write ES6 code and convert it back in pre-Es6 JavaScript that browser supports.

For example look the below code snippet.
In ES6 (ECMASCRIPT 2015)

const PI = 3.141593;
PI > 3.0 ;
export{PI};

In ES5 after conversion

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
var PI = 3.141593;
PI > 3.0;
exports.PI = PI;

Question 4) List steps to install Babel?

Installation: In order to install Babel, you require node.js and NPM. Make sure Node.js is installed on your server.

To check node installed or not run below commands on your terminal.

node -v 
npm -v

Installing Babel : We can install Babel CLI locally by running below command on terminal.

npm install --save-dev babel-cli

Question 5) What is Webpack?Webpack allows you to run an environment that hosts babel. Webpack is opensource javascript module bundler which takes modules with dependencies and generates static assets representing those modules.

Question 6) List benefits of using Webpack?Benefits of using Webpack.

  1. It bundles your multiple modules and packs it into a single .js file.
  2. It comes with integrated dev server. A small express app for local development. You simply include one Javascript tag pointed to the server, like localhost:8080/assets/bundle.js, and get live code updating and asset management for free.

Question 7) Explain Constants in Es6?

Constants also are known as immutable variables are a special type of variables whose content is not changed. In Es6 a constant is defined using const keyword. Constants in Es6 enable protection to overwrite a variable value, improve performance and helps programmers to write readable and cleaner code.

Example

In Es6

const WEBSITE_URL = "http://www.abc.com";
WEBSITE_URL="new url"; // generate an error;
console.log(WEBSITE_URL);

In prior version of Es6

//  and only in global context and not in a block scope 

Object.defineProperty(typeof global === "object" ? global : window, "WEBSITE_URL", { 
value: "http://www.abc.com", enumerable: true, 
writable:     false, 
configurable: false 
});

console.log(WEBSITE_URL);

Question 8) What are template literals in Es6?

Template literals are the string with embedded code and variables inside. Template literal allows concatenation and interpolation in much more comprehensive and clear in comparison with prior versions of ECMAScript.

Let see an example of concatenating a string in JavaScript.

var a="Hello";
var b="John";
var c = a+ " " + b;
Console.log(c); //outputs Hello John;

In ES6 concatenation and interpolation is done by backtick “ in a single line. To interpolate a variable simply put in to {} braces forwarded by $ sign.>/p>

// In ES6

let a="Hello";
let b="John";
let c=`${a} ${b}`;
console.log(c); //outputs Hello John;

Question 9) What is Spread Operator in ES6?Spread Operator provides a new way to manipulate array and objects in Es6.A Spread operator is represented by … followed by the variable name.

Example :

let a =[7,8,9];
let b=[1,2,3,...a,10];
console.log(b); // [1,2,3,7,8,9,10]

So spread operator spreads the contents of variable a and concatenates it in b.

Another Example

function print(...z){
	console.log(z); 
}

print(1,2,3,4);//[1,2,3,4]

Question 10) Explain Destructuring Assignment in ES6?

Destructing assignment in another improvement in Es6. It allows us to extract data from array and objects into separate variables.

Example

let full_name =['John','Deo'];

let [first_name,last_name]=full_name;

console.log(first_name,last_name);
// outputs John Deo

Another example

let c=[100,200,330,400];

let [a,...b]=c;

console.log(a,b);

// outputs 100 [200, 330, 400]

Question 11) How to create a Javascript class in ES6?In Es6 you can create a class using the Class keyword.Below is sample javascript class in ES6.

class User{
    constructor(name,age) {
        this.name  = name;
        this.age = age;
    }

    getData() {
        console.log(this.name + " is " + this.age + " years old !");
    }
}

var user = new User("foo", 7);
s1.getData();

Question 12) What is the use of let & const in JavaScript?

In modern javascript let & const are different ways of creating variables. Earlier in javascript, we use the var keyword for creating variables. let & const keyword is introduced in version ES6 with the vision of creating two different types of variables in javascript one is immutable and other is mutable.
const: It is used to create an immutable variable. Immutable variables are variables whose value is never changed in the complete life cycle of the program.
let: let is used to create a mutable variable. Mutable variables are normal variables like var that can be changed any number of time.

Question 13) What is Set in ES6?

Set is a collection of unique values. The values could be also primitives or object references.

Creating a Set in Javascript

let set = new Set();
set.add(1);
set.add('1');
set.add({ key: 'value' });
console.log(set); // Set {1, '1', Object {key: 'value'}}

Question 14) Explain Generator function in ES6?

Generators are functions that can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances. A function keyword followed by an asterisk defines a generator function, which returns a Generator object.

Generator Function Example.

function* generator(i) {
  yield i;
  yield i + 10;
}

var gen = generator(10);

console.log(gen.next().value);
// expected output: 10

console.log(gen.next().value);

Further reading: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*

Question 15) Explain WeakMap in ES6?

WeakMaps provide a way to extend objects from the outside without interfering with garbage collection. Whenever you want to extend an object but can’t because it is sealed – or from an external source – a WeakMap can be applied. WeakMap was also introduced by ES6 in 2015

Further reading : WeakMap in ES6

Got a Questions? Share with us

Ext js interview questions

Question 1) Explain What is EXT.js?
Question 2) List some features of Ext JS?
Question 3) Which architecture is supported by Ext JS?
Question 4) What is the latest stable version of Ext JS?
Question 5) List some advantages of using Ext JS.
Question 6) Explain limitations of using Ext JS.
Question 7) List out major Web browsers supported by Ext JS framework?
Question 8) What are the different type of alert boxes available in Ext JS?
Question 9) What is the difference between ext.js and ext-all.js file ?
Question 10) List EXT JS components?

Ext.js is pure Javascript framework that is used for building interactive cross-platform web applications such as desktops, tablets, and smartphones using techniques like Ajax, DHTML and DOM scripting. It provides pre-Integrated and tested UI Components such as HTML5 calendar, grids, pivot grid, D3.js

Read Best EXT Js interview Questions and answers here

Question 1) Explain What is EXT.js?

Ext.js is pure Javascript framework that is used for building interactive cross-platform web applications such as desktopstablets, and smartphones using techniques like AjaxDHTML and DOM scripting. It provides pre-Integrated and tested UI Components such HTML5 calendargridspivot grid, D3 adaptertreeslistsformsmenustoolbars, panelswindows, and much more. Read more from https://www.sencha.com/products/extjs/

Question 2) List some features of Ext JS?

Features of Ext Js : –

  • Pre-Integrated and Tested UI Components.
  • Rich Data Analytics.
  • Code compatibility of new versions with the older one
  • Sophisticated Data Visualization by supporting D3 js
  • A flexible layout manager helps to organize the display of data and content across multiple browsers, devices, and screen sizes
  • It is protocol agnostic and can access data from any back-end source.
  • Customizable Built-In Themes

Question 3) Which architecture is supported by Ext JS?

Ext JS provides support for both MVC (Model view controller) and MVVM (Model View ViewModel) application architectures. Both of these architectural approaches share certain concepts and focus on dividing application code along logical lines

Question 4) What is the latest stable version of Ext JS?

As on August 2018 latest stable version of Ext JS 6.2.1.

Question 5) List some advantages of using Ext JS.

  • Streamlines cross-platform development across desktops, tablets, and smartphones — for both modern and legacy browsers.
  • Increases the productivity of development teams by integrating into enterprise development environments via IDE plugins.
  • Reduces the cost of web application development.
  • Empowers teams to create apps with a compelling user experience.
  • It has set of widgets for making UI powerful and easy.
  • It follows MVC architecture so highly readable code.

Question 6) Explain limitations of using Ext JS.

  • The size of the library is large around 500 KB which makes initial loading time more and makes application slow.
  • HTML is full of tags makes it complex and difficult to debug.
  • According to general public license policy, it is free for open source applications but paid for commercial applications.
  • Sometimes for loading even simple things requires few lines of coding which is simpler in plain HTML or Jquery.
  • Need quite experienced developer for developing Ext JS applications.

Question 7) List out major Web browsers supported by Ext JS framework?

Below are list of browsers that are supported by Ext Js

  • Windows Internet Explorer version 6 and later
  • Mozilla Firefox version 1.5 and later (PC and Macintosh)
  • Apple Safari version 2 and later
  • Opera version 9 and later (PC and Mac)
  • Chrome10 and above

Question 8) What are the different type of alert boxes available in Ext JS?

Different type of alert boxes in Ext JS are

  • Ext.MessageBox.alert();
  • Ext.MessageBox.confirm();
  • Ext.MessageBox.wait();
  • Ext.MessageBox.promt();
  • Ext.MessageBox.show();

Question 9) What is the difference between ext.js and ext-all.js file ?

ext-all.js: This file contains the entire Ext JS framework (used for Development & testing)
ext.js: This file contains the minimum Ext JS code (Ext JS base library)- used in Production.

Question 10) List EXT JS components?

Ext JS has various UI components, we have listed some most used components are:

  • Window
  • Form
  • Message Box
  • Progress Bar
  • Grid
  • ToolTip
  • HTML Editor
  • Charts
Got a Questions? Share with us

Grunt js Interview Questions

Question 1) What is the application of Grunt in JavaScript?
Question 2) What are the factors concerning Grunt that a developer must focus on?
Question 3) What do you mean by Grunt?
Question 4) When compared to other programming languages how popular is Grunt?
Question 5) Is Grunt capable of automating a developer’s tasks?
Question 6) What is the prime motive of using automatic approach according to you and can it be beneficial in the long run?
Question 7) What does “Minification” mean in JavaScript? What is its importance?
Question 8) Can a developer check Js error using Grunt?
Question 9) How can you define Unit Testing in JavaScript? Does Grunt concern Unit Testing in any way?
Question 10) How can you define the role of Node.Js package manager while implementing Grunt?

Grunt is an automated task runner for Javascript. Grunt is used to automatically perform frequent tasks such as minification, compilation, unit testing, and linting. It uses a command-line interface to run custom tasks defined in a file.

Looking to build your career as a Grunt Js Developer in an MNC or a high-end corporate? Will you be soon appearing for your interviews? Well, if you are looking to prepare before you go one-on-one with the interviewer, you are in the right place. Most of the questions are covering the important aspects and have a high probability of being asked. Grunt developers can find themselves in some of the top MNC’s and if reports are to be believed, they hold 70.3% of the market. 

Read Top 10 Grunt js Interview questions and answers

Here are some of the Grunt.js Interview questions that might be asked during your interview:

Question 1) What is the application of Grunt in JavaScript?

A Grunt is a tool that helps in managing a code by saving both cost and time. When programmers write a code for a project based on programming language, they have to apply functions again and again. Grant makes the coding easy and simple and in case the project is really big then this tool alone can reduce the time required for completion to a great extent. Since JavaScript is implemented for developing a lot of applications, users can easily use this tool while on it.

Question 2)  What are the factors concerning Grunt that a developer must focus on?

Every developer looks for solutions which are quick and time-saving and Grunt can fulfill both the features. In order to get desirable results, it must be in its latest version. The latest version will remove any probability of errors and shall assure that code is written perfectly.

Question 3)  What do you mean by Grunt?

Grunt is a task runner in JavaScript that is often preferred by programmers and developers due to its features and ability to automate. Most of its functionality is unimaginable and results with a desirable outcome & zero error. The developer can do coding and test it using Grunt so that the project has no error and can save both time and money.

Question 4)  When compared to other programming languages how popular is Grunt?

Grunt, when compared to other programming languages, is popular for its features and functionality and often recommended by experts. It is a wonderful tool for testers who run tests on coding. If a project is large-scale and a developer is looking to finish it without any errors then they usually prefer Grunt. A lot of corporates use this managing tool to manage their projects and also save tie and money. Grunt can be related to two words i.e. accurate and reliable. Grunt can be used for any small or big project and can produce results under a certain timeline.

Question 5)  Is Grunt capable of automating a developer’s tasks?

The answer is Yes. Grunt has proved to be extremely efficient where it can automate several tasks and produce results, which do not have any errors or bugs in them. The coding, which is error free can be considered as the major requirement for an IT company. Using Grunt can help the big organizations cut down their huge investments on testing their codes, which is really important and beneficial.

Question 6)  What is the prime motive of using automatic approach according to you and can it be beneficial in the long run?

Grunt’s automatic approach has been beneficial for every developer since the day it was introduced. Grunt can automate tasks and produce results that are favorable. Programmers often use it for compiling and testing of various tasks thereby getting rid of any errors in no time. Thus, Grunt acts as a time saver.

Question 7)  What does “Minification” mean in JavaScript? What is its importance?

Minification occurs when Grunt makes the coding simple, easy and time-efficient. Every project that functions with the help of computer language requires coding. Since coding can include some repetitive tasks such as including functions every now and then, minification is required. Grunt helps in taking care of this repetitive task. Using minification, the developers can save both time & energy and it’s even better for companies who can reduce their investments that is usually required for big-scale projects.

Question 8)  Can a developer check Js error using Grunt?

Yes, the developer uses Grunt all the time for checking Js errors. Usually, Grunt checks the errors automatically even when it doesn’t receive the command from the user. In case the developer is looking to customize the outcome then various filters can be applied. When Grunt is applied for errors check, the probability of errors occurring becomes extremely less.

Question 9) How can you define Unit Testing in JavaScript? Does Grunt concern Unit Testing in any way?

A big project is subdivided into different teams and sections. As a result, the work of every team can be referred to as a unit. Thus, before the whole project is compiled together each unit undergoes testing. A project that is related to a computer language may have sub-sections, which are again called as units.When we consider Java, developers take a different approach. Now, Grunt is essential when the units are tested as it checks each and every unit one-by-one. The unit outcome is definitely good.

Question 10)  How can you define the role of Node.Js package manager while implementing Grunt?

Node.Js plays an essential role when it comes to proper installation of Grunt. For using the Grunt platform, the developer has to install it first, which is applicable for every similar application. With the help of npm, the Node.Js package manager shall successfully install the grunt plugin.

Got a Questions? Share with us

Gulp Js interview questions

Question 1) Please explain what is Gulp?
Question 2) How to install gulp?
Question 3) For what Gulp is used?
Question 4) How many streams are available in Gulp?
Question 5) What gulp.src function do?
Question 6) What is difference between Gulp and Grantjs?

Got a Questions? Share with us

Handlebars js interview questions

Question 1) Explain Handlebar.js ?
Question 2) What is current stable version of Handlebar.js ?
Question 3) How to install and configure Handlebar.js ?
Question 4) Explain Bower ?
Question 5) How HTML Escaping is done by Handlebar.js?
Question 6) How to add comments in Handlebar.js ?
Question 7) What are Helpers in Handlebar.js? how can you register it?
Question 8) What is partial ? How to register a partial in Handlebar.js?
Question 9) List some built in Helpers in Handlebar.js ?

Got a Questions? Share with us

JQuery Interview Questions

Question 1) What is jQuery?
Question 2) How is body onload() in JQuery is different from document.ready() function?
Question 3) What are features of JQuery or what can be done using JQuery?
Question 4) What are the different type of selectors in Jquery?
Question 5) What are the advantages of JQuery ?
Question 6) Why jQuery?
Question 7) What is jQuery Selectors? Give some examples
Question 8) Explain width() vs css(‘width’) in JQuery
Question 9) Explain bind() vs live() vs delegate() methods in Jquery
Question 10) What is the use of param() method in JQuery .
Question 11) What is the difference between jquery.size() and jquery.length?
Question 12) How to read, write and delete cookies in jQuery ?
Question 13) What is difference between $(this) and this in jQuery ?
Question 14) What are the various ajax functions available in Jquery ?
Question 15) Explain .empty() vs .remove() vs .detach() in Jquery
Question 16) How can events be prevented from stopping to work after an ajax request?

What is Jquery

A lightweight JavaScript library which gives a quick and simple method for HTML DOM traversing and manipulation, its event handling, its client-side animations, and so on.

Quick Questions About Jquery
JQuery is written InJava Script
Jquery is aJavascript library designed to simplify HTML DOM, tree traversal and manipulation.
JQuery is developed ByJohn Resig
JQuery is Designed forSelect DOM elements,Create Animations,Handle events,develop Ajax applications
JQuery LicenceMIT
JQuery Current Stable release3.4.1
Below are the list of Best JQuery Interview Questions and Answers
Question 1) What is jQuery?
jQuery is a lightweight JavaScript library which gives a quick and simple method for HTML DOM traversing and manipulation, its event handling, its client-side animations, and so on. One of the best features of jQuery is that jQuery supports an efficient way to implement AJAX applications because of its lightweight nature and make normalize and efficient web programs. 

Question 2) How is body onload() in JQuery is different from document.ready() function?
Document.ready() function is different from body onload() function because off 2 reasons.
We can have more than one document.ready() function in a page where we can have only one onload function.
Document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.

Question 3) What are features of JQuery or what can be done using JQuery?
Features of Jquery
One can easily provide effects and can do animations.
Applying / Changing CSS.
Cool plugins.
Ajax support
DOM selection events
Event Handling

Question 4) What are the different type of selectors in Jquery?
There are 3 types of selectors in Jquery
CSS Selector
XPath Selector
Custom Selector

Question 5) What are the advantages of JQuery ?
There are many advantages of using JQuery. Some of them are :
It is more like a JavaScript enhancement so there is no overhead in learning a new syntax.
It has the ability to keep the code simple, readable, clear and reusable.
Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
It would eradicate the requirement for writing complex loops and DOM scripting library calls.
Event detection and handling.
Tons of plug-ins for all kind of needs.

Question 6) Why jQuery?
jQuery is very compact and well-written JavaScript code that increases the productivity of the developer by enabling them to achieve critical UI functionality by writing very less amount of code.
It helps to
Improve the performance of the application
Develop most browser compatible web page
Implement UI related critical functionality without writing hundreds of lines of codes
Fast
Extensible – jQuery can be extended to implement customized behavior
Other advantages of jQuery are
No need to learn fresh new syntax’s to use jQuery, knowing simple JavaScript syntax is enough
Simple and Cleaner code, no need to write several lines of codes to achieve complex functionality.

Question 7) What is jQuery Selectors? Give some examples
jQuery Selectors are used to select one or a group of HTML elements from your web page.
jQuery support all the CSS selectors as well as many additional custom selectors.
jQuery selectors always start with dollar sign and parentheses: $()
There are three building blocks to select the elements in a web document.
1. Select elements by tag name
Example
$(div)
It will select all the div elements in the document.
2. Select elements by ID
Example
$(“#abc”)
It will select single element that has an ID of abc.
3. Select elements by Class
Example
$(“.xyzClass”)
It will select all the elements having class xyzClass.

Question 8) Explain width() vs css(‘width’) in JQuery
In jQuery, there is two way to change the width of an element. One way is using .css(‘width’) and other way is using .width().
For example
$('#mydiv').css('width','300px'); $('#mydiv').width(100); 
The difference in .css(‘width’) and .width() is the data type of value we specify or return from the both functions.
In .css(‘width’) we have to add “px” in the width value while in .width() we don’t have to add.
When you want to get the width of “mydiv” element then .css(‘width’) will return ‘300px’ while .width() will return only integer value 300.

Question 9) Explain bind() vs live() vs delegate() methods in Jquery
The bind() method will not attach events to those elements which are added after DOM is loaded while live() and delegate() methods attach events to the future elements also.
The difference between live() and delegate() methods is live() function will not work in chaining. It will work only on an selector or an element while delegate() method can work in chaining.
For example
$(document).ready(function(){ $("#myTable").find("tr").live("click",function(){ alert($(this).text()); }); }); 
Above code will not work using live() method. But using delegate() method we can accomplish this.
$(document).ready(function(){ $("#dvContainer")children("table").delegate("tr","click",function(){ alert($(this).text()); }); }); 

Question 10) What is the use of param() method in JQuery .
The param() method is used to represent an array or an object in serialize manner.
While making an ajax request we can use these serialize values in the query strings of URL.
Syntax:
$.param(object | array, boolValue)
“object | array” specifies an array or an object to be serialized.
“boolValue” specifies whether to use the traditional style of param serialization or not.
Example
personObj=new Object(); empObject.name="Ravi"; empObject.age="28"; empObject.dept="IT"; $("#clickme").click(function(){ $("span").text($.param(empObject)); }); 
It will set the text of span to “name=Ravi&age=28&dep=IT”

Question 11) What is the difference between jquery.size() and jquery.length?
jQuery .size() method returns number of element in the object. But it is not preferred to use the size() method as jQuery provide .length property and which does the same thing. But the .length property is preferred because it does not have the overhead of a function call.

Question 12) How to read, write and delete cookies in jQuery ?
To deal with cookies in jQuery we have to use the Dough cookie plugin.
Dough is easy to use and having powerful features.
Create cookie:
$.dough(“cookie_name”, “cookie_value”);
Read Cookie:
$.dough(“cookie_name”);
Delete cookie:
$.dough(“cookie_name”, “remove”);

Question 13) What is difference between $(this) and this in jQuery ?
$(document).ready(function(){ $('#clickme').click(function(){  alert($(this).text());  alert(this.innerText); }); }); 
this and $(this) references the same element but the difference is that “this” is used in traditional way but when “this” is used with $() then it becomes a jQuery object on which we can use the functions of jQuery.?
In the example given, when only “this” keyword is used then we can use the jQuery text() function to get the text of the element, because it is not jQuery object. Once the “this” keyword is wrapped in $() then we can use the jQuery function text() to get the text of the element.

Question 14) What are the various ajax functions available in Jquery ?
Ajax allows the user to exchange data with a server and update parts of a page without reloading the entire page. Some of the functions of ajax are as follows:
$.ajax(): This is considered to be the most low level and basic of functions. It is used to send requests . This function can be performed without a selector.
$.ajaxSetup(): This function is used to define and set the options for various ajax calls.
For example.
$.ajaxSetup({ "type":"POST", "url":"ajax.php", "success":function(data){ $("#bar") .css("background","yellow") .html(data); } });
Shorthand ajax methods: They comprise of simply the wrapper function that call $.ajax() with certain parameters already set.
$.getJSON(): this is a special type of shorthand function which is used to accept the url to which the requests are sent. Also optional data and optional callback functions are possible in such functions.

Question 15) Explain .empty() vs .remove() vs .detach() in Jquery
.empty() method is used to remove all the child elements from matched elements.
.remove() method is used to remove all the matched element. This method will remove all the jQuery data associated with the matched element.
.detach() method is same as .remove() method except that the .detach() method doesn’t remove jQuery data associated with the matched elements.
.remove() is faster than .empty() or .detach() method.
Syntax:
$(selector).empty(); $(selector).remove(); $(selector).detach(); 

Question 16) How can events be prevented from stopping to work after an ajax request?
There are two ways to handle this issue:
Use of event delegation: The event delegation technique works on principle by exploiting the event bubbling. It uses event bubbling to capture the events on elements which are present anywhere in the domain object model. In jquery the user can make use of the live and die methods for the events delegation which contains a subset of event types.
For example. handling even delegation, handling of clicks on any <a> element:
$('#mydiv').click(function(e){ if( $(e.target).is('a') ) fn.call(e.target,e); }); $('#mydiv').load('my.html') 
Event rebinding usage: When this method is used it requires the user to call the bind method and the added new elements.
$('a').click(fn); $('#mydiv').load('my.html',function(){ $('#mydiv a').click(fn); }); 


Got a Questions? Share with us 

JSON Interview Questions

Question 1) What is JSON? For what is used for?
Question 2) How to convert Javascript objects into JSON?
Question 3) List types Natively supported by JSON?
Question 4) What does Object.create do?
Question 5) What does hasOwnProperty method do?
Question 6) What does $.parseJSON() do ?
Question 7) What are different ways to create objects?
Question 8) What is the default value of a constructor’s prototype?
Question 9) List some benefits of JSON over XML?
Question 10) What is the difference between JSON and JSONP?
Question 11) Who is the Father of JSON and What is the scripting language JSON is based on?
Question 12) What is JSON-RPC? List some Features of JSON-RPC-Java
Question 13) What are natively supported JSON types?
Question 14) What is BSON?
Question 15) How to convert an Object into JSON? What is the full syntax of JSON.stringify?
Question 16) What JS-specific properties are skipped by JSON.stringify method?
Question 17) How do you decode a JSON string?
Question 18) How to delete an index from JSON Obj?

Question 1) What is JSON? For what is used for?JSON (JavaScript Object Notation) is a data storage and communication format based on key-value pair of JavaScript object literals. It is a lightweight text-based open standard designed for human-readable data interchange which is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects.

In JSON

  • all property names are surrounded by double quotes.
  • values are restricted to simple data: no function calls, variables, comments, or computations.

JSON is used for communication between javascript and serverside technologies.

Question 2) How to convert Javascript objects into JSON?JSON.stringify(value); is used to convert Javascript objects into JSON.

Example Usage:

    var obj={"website":"Onlineinterviewquestions"};
    JSON.stringify(obj); // '{"website":"Onlineinterviewquestions"}'

Question 3) List types Natively supported by JSON?JSON supports Objects, Arrays, Primitives (strings, numbers, boolean values (true/false), null) data types.

Question 4) What does Object.create do?Object.create creates a new object with the specified prototype object and properties.

Question 5) What does hasOwnProperty method do?It returns true if the property was set on an actual object rather than inherited.

Question 6) What does $.parseJSON() do ?$.parseJSON() takes a well-formed JSON string and returns the resulting JavaScript value.

Question 7) What are different ways to create objects?You can create Object by

  • object literals
  • Object.create
  • constructors

Question 8) What is the default value of a constructor’s prototype?A plain, empty object that derives from Object.prototype is the default value of a constructor’s prototype

Question 9) List some benefits of JSON over XML?

  • It is faster and lighter than XML as on the wire data format
  • XML data is typeless while JSON objects are typed
  • JSON types: Number, Array, Boolean, String
  • XML data are all string
  • Data is readily available as JSON object is in your JavaScript
  • Fetching values is as simple as reading from an object property in your JavaScript code

Question 10) What is the difference between JSON and JSONP?

  • JSON: JSON is a simple data format used for communication medium between different systems
  • JSONP: It is a methodology for using that format with cross-domain ajax requests while not being affected by same origin policy issue.

Question 11) Who is the Father of JSON and What is the scripting language JSON is based on?Douglas Crockford called as the Father of JSON. JSON is based on ECMAScript.

Question 12) What is JSON-RPC? List some Features of JSON-RPC-JavaJSON-RPC: JSON-RPC is a simple remote procedure call protocol similar to XML-RPC although it uses the lightweight JSON format instead of XML.

JSON-RPC-Java is a Java implementation of the JSON-RPC protocol.Below is list of some of its features

  • Dynamically call server-side Java methods from JavaScript DHTML web applications. No Page reloading.
  • Asynchronous communications.
  • Transparently maps Java objects to JavaScript objects.
  • Lightweight protocol similar to XML-RPC although much faster.
  • Leverages J2EE security model with session specific exporting of objects.
  • Supports Internet Explorer, Mozilla, Firefox, Safari, Opera, and Konqueror.

Question 13) What are natively supported JSON types?Following data types are natively supported in JSON.

  • Numbers: Integer, float or Double
  • String: string of Unicode characters, must be rapped into double quotes “”
  • Boolean: True or false
  • Array: ordered list of 0 or more values
  • Objects : An unordered collection key/ value pairs
  • Null: An Empty value

Question 14) What is BSON?BSON is the superset of JSON, which used by MongoDB.BSON supports the embedding of documents and arrays within other documents and arrays. BSON also contains extensions that allow representation of data types that are not part of the JSON spec.

Question 15) How to convert an Object into JSON? What is the full syntax of JSON.stringify?JSON.stringify method is used to convert an Javascript Object into JSON.
Syntax:

let json = JSON.stringify(value[, replacer, space])

Question 16) What JS-specific properties are skipped by JSON.stringify method?Following JS-specific properties are skipped by JSON.stringify method

  • Function properties (methods).
  • Symbolic properties.
  • Properties that store undefined.

Question 17) How do you decode a JSON string?Use JSON.parse method to decode a JSON string into a Javascript object.Question 18) How to delete an index from JSON Obj?Deleting an Element from JSON Obj

var exjson = {'key':'value'};
delete exjson['key'];

Knockout Js Interview Questions

  • Question 1) What is Knockout JS?
  • Question 2) What is the features of Knockout JS?
  • Question 3) Types of data binding supported by Knockout JS?
  • Question 4) What is an observable in KnockoutJS?
  • Question 5) What are Components in Knockout JS?
  • Question 6) Describe ViewModel in Knockout Js?
  • Question 7) How to check an observable is null in knockout js?
  • Question 8) How can you format currency in knockout.js

Question 1) What is Knockout JS?

Knockout JS is an open source JavaScript library based on MVVM (Model View ViewModel) pattern that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model.
Knockout JS is small light weighted JavaScript library that is mostly used for designing a SPA (Single Page Application).

Question 2) What is the features of Knockout JS?

Key Features of Knockout JS

  • Dependency Tracking
  • Declarative Binding
  • MVVM Design Pattern
  • Automatic UI Refresh
  • Template Binding
  • Written in Pure JavaScript
  • Compact Size less than 20 kb.
  • Support all modern browsers
  • Easy to implement

Question 3) Types of data binding supported by Knockout JS?

Knockout js supported two types of binding

  • One-way binding
  • Two-way binding

Question 4) What is an observable in KnockoutJS?

Observables: In KnockoutJS observables are special type of JavaScript objects that can notify subscribers about changes, and can automatically detect dependencies. Observables helps KnockoutJS to update your UI automatically when the view model changes.

Creating an Observable in KnockoutJS

var myViewModel = {
    personName: ko.observable('Bob'),
    personAge: ko.observable(123)
};

Question 5) What are Components in Knockout JS?

Components are a powerful, clean way of organizing your UI code into self-contained, reusable chunks.They:

  • ..can represent individual controls/widgets, or entire sections of your application
  • ..contain their own view, and usually (but optionally) their own viewmodel
  • ..can either be preloaded, or loaded asynchronously (on demand) via AMD or other module systems
  • ..can receive parameters, and optionally write back changes to them or invoke callbacks
  • ..can be composed together (nested) or inherited from other components
  • ..can easily be packaged for reuse across projects
  • ..let you define your own conventions/logic for configuration and loading

Question 6) Describe ViewModel in Knockout Js?

A viewModel in Knockout js is a basic class that is created as JavaScript Function.It is declared as a variable that have member variables and methods.


var myViewModel = {
		personName: 'Bob',
		personAge: function(age){
		 return  age+"years old";
		 }
	};

Question 7) How to check an observable is null in knockout js?

Question 8) How can you format currency in knockout.js

Koa Js Interview questions

elow are the list of Best Koa Js Interview questions and AnswersQuestion 1) List some key features of koa.js?

  • Lightweight and modular.
  • No callback hell.
  • Better error handling through try/catch.
  • Better user experience.
  • Proper stream handling.

Question 2) Explain Koa Js?

Koa js modular lightweight web application framework for Node JS.

Question 3) List few difference between Koa and Express.

Below is the list of few differences between Koa and Express.

  • Koa aims to “fix and replace node” whereas Express “augments node”
  • Koa uses promises and async functions to rid off callback hell whereas Express uses req and res.
  • Koe does not support features likes routing and templating whereas Express supports routing and templating.

Marionette js interview questions

Question 1) What is Marionette.js ?
Question 2) List some features of Marionette.js ?
Question 3) What is current stable version of Marionette.js ?
Question 4) How to install and configure Marionette.js ?
Question 5) How can you intialize Marionette.js ?
Question 6) Explain how to trigger and listen Events in Marionette.js ?
Question 7) How to configure Routes in Marionette.js ?
Question 8) How to set a Renderer in Marionette.js?
Question 9) What Marionette getTemplate function does ?
Question 10) How to create a Model in Marionette?

Phantomjs Interview Questions

Question 1) What is phantomjs?
Question 2) Enlist some difference between puppeteer and phantomjs?
Question 3) List major features of phantomjs?
Question 4) What is Headless Testing?
Question 5) What objects are avaialable in phantomjs?
Question 6) How to delete Cookie in phantomjs?
Question 7) How to enable Cookie In Phantomjs?
Question 8) How to run test scripts in Selenium using PhantomJS?

JavaScript Interview Questions

What is Javascript

Javascript is a scripting language(supports scripts) for Web pages but it is also used in non-browser environments as well. It is a powerful, lightweight, interpreted, scripting language with first-class functions (i.e. the language supports passing functions as arguments to other functions).

In order to add the dynamic interactivity to web pages Javascript is embedded within Hypertext Markup Language (HTML). Since it runs on the client side of the web so it can be used to design/program how the web pages behave on the occurrence of a particular event. That’s the reason why it is widely used for the behavior of the web pages.

Quick Questions About Javascript
JavaScript is also known asJS
JavaScript is ais a high-level, interpreted scripting language.
JavaScript is developed ByNetscape Communications Corporation, Mozilla Foundation, Ecma International
JavaScriptis designed byBrendan Eich
JavaScript Filename extension’s are.js
JavaScript Media type isapplication/javascript, text/javascript
JavaScript Current VersionECMAScript 2018

Read Advanced and Basic Javascript Interview Questions and Answers. We have listed some Javascript Developer interview questions with their answers that help you to crack javascript interviews

Below are the list of Best Advanced and Basic JavaScript Interview Questions and Answers

Question 1. Explain what is Javascript? List some data types supported by Javascript?

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). Javascript syntax looks a lot like java, c or c++ syntax.

Below is the list of data types supported by Javascript:-

  • Undefined
  • Null
  • Boolean
  • String
  • Symbol
  • Number
  • Object

Question 2. What close() does in Javascript?

In Javascript close() method is used to close the current window. You must write window.close() to ensure that this command is associated with a window object and not some other JavaScript object.

Question 3. What is the difference between let and var?

Both var and let are used for variable/ method declaration in javascript but the main difference between let and var is that var is function scoped whereas let is block scoped.

Question 4. Explain Closures in JavaScript?

Closures are the combination of lexical environment and function within which the function was declared. This allows JavaScript programmers to write better, more creative, concise and expressive codes. The closure will consist of all the local variables that were in-scope when the closure was created.

Sure, closures appear to be complex and beyond the scope, but after you read this article, closures will be much more easy to understand and more simple for your everyday JavaScript programming tasks. JavaScript is  a very function-oriented language it gives the user freedom to use functions as the wish of the programmer.

Question 5. Explain JavaScript Event Delegation Model?

In JavaScript, there is some cool stuff that makes it the best of all. One of them is Delegation Model. When capturing and bubbling, allow functions to implement one single handler to many elements at one particular time then that is called event delegation. Event delegation allows you to add event listeners to one parent instead of specified nodes. That particular listener analyzes bubbled events to find a match on the child elements. Many people think it to be complicated but in reality, it is very simple if one starts understanding it.

Also, Read Five JavaScript Frameworks to learn in 2018

Question 6. Describe negative infinity in JavaScript?

NEGATIVE_INFINITY property represents negative infinity and is a number in javascript, which is derived by ‘dividing negative number by zero’. It can be better understood as a number that is lower than any other number. Its properties are as follows:
– A number of objects need not to be created to access this static property.
– The value of negative infinity is the same as the negative value of the infinity property of the global object.

The values behave differently than the mathematical infinity:

  1. Any positive value, including POSITIVE_INFINITY, multiplied by NEGATIVE_INFINITY is NEGATIVE_INFINITY.
  2. Any negative value, including NEGATIVE_INFINITY, multiplied by NEGATIVE_INFINITY is POSITIVE_INFINITY.
  3. Zero multiplied by NEGATIVE_INFINITY is NaN.
  4. NaN multiplied by NEGATIVE_INFINITY is NaN.
  5. NEGATIVE_INFINITY, divided by any negative value except NEGATIVE_INFINITY, is POSITIVE_INFINITY.
  6. NEGATIVE_INFINITY, divided by any positive value except POSITIVE_INFINITY, is NEGATIVE_INFINITY.
  7. NEGATIVE_INFINITY, divided by either NEGATIVE_INFINITY or POSITIVE_INFINITY, is NaN.
  8. Any number divided by NEGATIVE_INFINITY is zero.

Question 7. Explain function hoisting in JavaScript?

JavaScript’s default behavior that allows moving declarations to the top is called Hoisting. The 2 ways of creating functions in JavaScript are Function Declaration and Function Expression. Let’s find out more about these:

Function Declaration

A function with the specific parameters is known as function declarations. To create a variable in JavaScript is called declarations.

e.g:

hoisted(); // logs "foo"

function hoisted() {

  console.log('foo');

}

Function Expression

When a function is created by using an expression it is called function expression.

e.g:

notHoisted(); // TypeError: notHoisted is not a function

var notHoisted = function() {

   console.log('bar');

};

Question 8. What is the use of let & const in JavaScript?

In modern javascript let & const are different ways of creating variables. Earlier in javascript, we use the var keyword for creating variables. let & const keyword is introduced in version ES6 with the vision of creating two different types of variables in javascript one is immutable and other is mutable.
const: It is used to create an immutable variable. Immutable variables are variables whose value is never changed in the complete life cycle of the program.
let: let is used to create a mutable variable. Mutable variables are normal variables like var that can be changed any number of time.

Question 9. Explain Arrow functions?

An arrow function is a consise and short way to write function expressions in Es6 or above.A rrow functions cannot be used as constructors and also does not supports this, arguments, super, or new.target keywords. It is best suited for non-method functions. In general an arrow function looks like const function_name= ()=>{}

 const greet=()=>{console.log('hello');}
 greet();
 

Question 10. What are exports and imports?

Imports and exports help us to write modular javascript code. Using Imports and exports we can split our code into multiple files. Imports allow taking only some specific variables or methods of a file. We can import methods or variables that are exported by a module. See the below example for more detail.

 //index.js

 import name,age from './person'; 

 console.log(name);
 console.log(age);

 //person.js

 let name ='Sharad', occupation='developer', age =26;

 export { name, age}; 

Question 11. What is difference between module.exports and export?

The module is a plain JavaScript object with an exports property. Exports is a plain JavaScript variable that happens to be set to module.exports. At the end of your file, node.js will basically ‘return’ module.exports to the require function. A simplified way to view a JS file in Node could be this:

var module = { exports: {} };
var exports = module.exports;

// your code
return module.exports;

If you set a property on exports, like exports.a = 9;, that will set module.exports.a as well because objects are passed around as references in JavaScript, which means that if you set multiple variables to the same object, they are all the same object; so then exports and module.exports are the same objects.
But if you set exports to something new, it will no longer be set to module.exports, so exports and module.exports are no longer the same objects.

Source : https://stackoverflow.com/questions/16383795/difference-between-module-exports-and-exports-in-the-commonjs-module-system

Question 12. How to import all exports of a file as an object.

import * as object name from ‘./file.js’ is used to import all exported members as an object. You can simply access the exported variables or methods using dot (.) operator of the object.

Example:

objectname.member1;
objectname.member2;
objectname.memberfunc();

Question 13. Explain “use strict” ?

“use strict” is a javascript directive that is introduced in Es5. The purpose of using “use strict” directive is to enforce the code is executed in strict mode. In strict mode we can’t use a variable without declaring it. “use strict” is ignored by earlier versions of Javascript.

Question 14. Explain Event bubbling and Event Capturing in JavaScript?

Event Capture and Bubbling: In HTML DOM API there are two ways of event propagation and determines the order in which event will be received. The two ways are Event Bubbling and Event Capturing. The first method event bubbling directs the event to its intended target, and the second is called event capture in which the event goes down to the element.

Event Capture

The capture procedure is rarely used but when it’s used it proves to be very helpful. This process is also called ‘trickling’. In this process, the event is captured first by the outermost element and then propagated to the innermost element. For example:

<div>

<ul>

<li></li>

</ul>

</div>

From the above example, suppose the click event did occur in the ‘li’ element, in that case capturing event it will be first handled ‘div’, then ‘ul’ and at last the target element will be hit that is ‘li’

Event Bubbling

Bubbling just works like the bubbles, the event gets handled by the innermost element and then propagated to the outer element.

<div>
 <ul>

<li></li>

</ul>

</div>

From the above example, suppose the click event did occur in the ‘li’ element in bubbling model the event will be handled first by ‘li’ then by ‘ul’ and at last by ‘div’ element.

Question 15. In Javascript are calculations with fractional numbers guaranteed to be precise?

NO, calculations with fractional numbers are not guaranteed to be precise in Javascript

Question 16. List the comparison operators supported by Javascript?

Javascript supports below comparison operators

  • > Greater than
  • < Less than
  • <= Less than or equal to
  • >= Greater than or equal to
  • == Equal to
  • != Not Equal to
  • === Equal to with datatype check
  • !== Not equal to with datatype check

Question 17. How do you declare variables in Javascript?

In Javascript variable are declared using the var keyword.A variable must begin with A letter$ or _.

eg. var myVar=”Online Interview Questions”;

PS: All variables in Javascript are Case sensitive.

Also, read Advanced JavaScript Interview Questions

Question 18. What will happen if an infinite while loop is run in Javascript?

The program will crash the browser.

Question 19. List HTML DOM mouse events?

HTML DOM mouse events

  • onclick
  • ondblclick
  • mousemove
  • mousedown
  • mouseover
  • mouseout
  • mouseup

Question 20. How to get the last index of a string in Javascript?

string.length-1 is used to get the last index of a string in Javascript

Example Usage:-

var myString="JavascriptQuestions";
console.log(myString.length-1);

Question 21. How to get the primitive value of a string in Javascript?

In Javascript valueOf() method is used to get the primitive value of a string.

Example Usage:

var myVar= "Hi!"
console.log(myVar.valueOf())

Question 22. What are the primitive data types in JavaScript?

A primitive is a basic data type that’s not built out of other data types. It can only represent one single value. All primitives are built-in data types by necessity, (the compiler has to know about them,) but not all built-in data types are primitives.

In JavaScript there are 5 primitive data types are available they are undefinednullbooleanstring and number are available.Everything else in Javascript is an object.

Question 23. What does the instanceof operator do?

In Javascript instanceof operator checks whether the object is an instance of a class or not:

Example Usage

Square.prototype = new Square();
console.log(sq instanceof Square); // true

Question 24. What is Javascript BOM?

BOM stands for “Browser Object Modal” that allows Javascript to ‘talk’ to the browser, no standards, modern browsers implement similar BOMS – window, screen, location, history, navigator, timing, cookies.

Question 25. What are different types of Popup boxes available in Javascript?

In Javascript there are 3 types of Popup Boxes are available, they are

  • Alert
  • Confirm
  • Prompt

Read 80+ Best Angular Js Interview Questions

Question 26. How can you create an array in Javascript?

There are 3 different ways to create an array in Javascript. They are

  • By array literal
    usage: var myArray=[value1,value2…valueN];
  • By creating instance of Array
    usage:var myArray=new Array();
  • By using an Array constructor
    usage:var myArray=new Array(‘value1′,’value2′,…,’valueN’);

Question 27. What is the ‘Strict’ mode in JavaScript and how can it be enabled?

Strict mode is a way to introduce better error-checking into your code. When you use strict mode, you cannot, for example, use implicitly declared variables, or assign a value to a read-only property, or add a property to an object that is not extensible.

You can enable strict mode by adding “use strict”; at the beginning of a file, a program, or a function. This kind of declaration is known as a directive prologue. The scope of a strict mode declaration depends on its context. If it is declared in a global context (outside the scope of a function), all the code in the program is in strict mode. If it is declared in a function, all the code in the function is in strict mode.

Question 28. How to calculate Fibonacci numbers in JavaScript?

Calculating Fibonacci series in JavaScript

Fibonacci numbers are a sequence of numbers where each value is the sum of the previous two, starting with 0 and 1. The first few values are 0, 1, 1, 2, 3, 5, 8, 13 ,…,

function fib(n) {
	var a=0, b=1;
	for (var i=0; i < n; i++) {
		var temp = a+b; 
		a = b;
		b = temp;
	}
	return a;
}

Question 29. What is the difference between the substr() and substring() functions in JavaScript?

Difference between the substr() and substring() functions in JavaScript.

The substr() function has the form substr(startIndex,length). It returns the substring from startIndex and returns ‘length’ number of characters.

var s = "hello";
( s.substr(1,4) == "ello" ) // true

The substring() function has the form substring(startIndex,endIndex). It returns the substring from startIndex up to endIndex – 1.

var s = "hello";
( s.substring(1,4) == "ell" ) // true

Question 30. What are different types of Inheritence? Which Inheritance is followed in Javascript.

There are two types of Inherientence in OOPS Classic and Prototypical Inheritance. Javascript follows Prototypical Inheritance.

Question 31. What is output of undefined * 2 in Javascript?

nan is output of undefined * 2.

Question 32. How to add/remove properties to object dynamically in Javascript?

You can add a property to an object using object.property_name =value, delete object.property_name is used to delete a property.

Example:

    let user = new Object();
    // adding a property
    user.name='Anil';
    user.age  =25;
    console.log(user);
    delete user.age;
    console.log(user);

Question 33. How to convert Javascript date to ISO standard?

toISOString() method is used to convert javascript date to ISO standard. It converts JavaScript Date object into a string, using the ISO standard.

Usage:

var date = new Date();
var n = date.toISOString();
console.log(n);
// YYYY-MM-DDTHH:mm:ss.sssZ

Question 34. How to get inner Html of an element in JavaScript?

InnerHTML property of HTML DOM is used to get inner Html of an element in JavaScript.

Example Usage:This is inner Element

<script type="text/javascript">
	var  inner= document.getElementById("inner").innerHTML ;
	console.log(inner); // This is inner Element
	document.getElementById("inner").innerHTML = "Html changed!";
	var  inner= document.getElementById("inner").innerHTML ;
	console.log(inner); // Html changed!
</script>

Question 35. How to clone an object in Javascript?

Object.assign() method is used for cloning an object in Javascript.Here is sample usage

	var x = {myProp: "value"};
	var y = Object.assign({}, x); 

Question 36. List different ways of empty an array in Javascript?

In Javascript, there are many ways to empty an array in Javascript, below we have listed 4 major

  • By assigning an empty array.var arr1 =[1,4,5,6]; arr1=[];
  • By assigning array length to 0.var arr2 =[1,4,5,6]; arr2.length=0;
  • By poping the elements of the array.var arr2 =[1,4,5,6]; while(arr.length > 0) { arr.pop(); }
  • By using .splice() .var arr =[1,4,5,6]; arr.splice(0,arr.length)

Question 37. How to get an element by class in JavaScript ?

document.getElementsByClassName() method is used in Javascript to get an element with a class name.

getElementsByClassName()
Method NamegetElementsByClassName
Syntaxdocument.getElementsByClassName(‘className’)
ParameterString (name of class)
OutputArray of HTMLCollection that have inputted className

Question 38. Explain Typecasting in Javascript?

In Programming whenever we need to convert a variable from one data type to another Typecasting is used. In Javascript, we can do this via library functions. There are basically 3 typecasts are available in Javascript Programming, they are:

  • Boolean(value): Casts the inputted value to a Boolean
  • Number(value): Casts the inputted value to an Integer or Floating point Number.
  • String(value) : Casts the inputted value value a string

Question 39. How to encode and decode a URL in JavaScript?

encodeURI() function is used to encode an URL in Javascript.It takes a url string as parameter and return encoded string. Note: encodeURI() did not encode characters like / ? : @ & = + $ #, if you have to encode these characters too please use encodeURIComponent(). Usage:

var uri = "my profile.php?name=sammer&occupation=pāntiNG";
var encoded_uri = encodeURI(uri);

decodeURI() function is used to decode an URL in Javascript.It takes a encoded url string as parameter and return decoded string. Usage:

var uri = "my profile.php?name=sammer&occupation=pāntiNG";
var encoded_uri = encodeURI(uri);
decodeURI(encoded_uri);

Question 40. How to you change the title of the page by JavaScript?

You can change the title of a webpage using setting the title property of the document object.

Example usage

document.title="My New Title";

Question 41. What is difference between deep and shallow object coping in JavaScript?

Some differences are:

  • Deep copy means copies all values or properties recursively in the new object whereas shallow copy copies only the reference.
  • In a deep copy, changes in the new object don’t show in original object whereas, in shallow copy, changes in new objects will reflect in the original object.
  • In a deep copy, original objects do not share the same properties with new object whereas, in shallow copy, they do.

Question 42. List some Unit Testing Frameworks JavaScript

Below is the list of few most Popular Javascript Unit Testing Frameworks:

  • Unit.js
  • Jasmine
  • Karma
  • Chai
  • AVA
  • Mocha
  • JSUnit
  • QUnit
  • Jest

Question 43. How to add a new property in existing function JavaScript?

It is easy to add a new property in existing function by just giving value to the existing function it. For example, let we have an existing object person, to give new property check the below code:

person.country= “India”;

The new property “country” has added to the object person.

Question 44. Explain JavaScript Accessors ?

JavaScript Accessors

Question 45. List few difference between primitive and non primitive JavaScript data types?

  • The primitive data types are numbers, strings, Boolean, undefined, null and anything other than these data types are known as non-primitive such as objects and functions.
  • Primitive data types are immutable while non-primitives are mutable.
  • Primitives are known immutable as they can’t be changed once they created but non-primitive are changeable, means once an object is created, it can be changed.
  • Primitives data types are compared with their values, it means two values are strictly equal if they have the same data type and holds the same value.
  • Non-primitives are not compared with values. For example, if two objects have the same properties and values, they are strictly not equal.

Question 46. Explain higher-order functions in JavaScript?

Higher order function is the best feature of functional programming available in JavaScript. It is the function which takes a function as an argument and returns a function as a result. Some of the inbuilt higher-order functions are mapping, filtering, reduction, zipping, etc.

Question 47. Explain few difference between null, undefined or undeclared JavaScript variable?

Null is a value that can be assigned to a variable or an object.

Undefined means a variable has been declared but no value is assigned to it. This type of variable is declared itself to be undefined.

Undeclared means the variable has declared without any datatype.

Null, Undefined are primitive data types whereas Undeclared is not a primitive data type.

Question 48. How host objects are different from native objects in JavaScript?

Host objects: These are those objects which environment gives. It means they are different for different environments. For example, browsers include objects such as windows but Node.js environments give objects such as Node List.

Native Objects: these are built-in objects in JavaScript. They are also known as Global Objects because they will be available to you independent of ay environment if you working in JavaScript.

Question 49. What is difference between var x =1; and x=1;?

Question 50. Explain spread operator in JavaScript?

The spread operator expands an expression in places where multiple argument/variables/elements are needed to present. It represents with three dots (…).

For example:

var mid = [3, 4];

var newarray = [1, 2, …mid, 5, 6];

console.log(newarray);

// [1, 2, 3, 4, 5, 6]

In above example, instead of appending mid array, it rather expands in the newarray with the help of spread operator. This is how spread operator works in JavaScript.

Question 51. How to remove duplicates from JavaScript Array?

There are many ways to remove duplicates from JavaScript array. These are described below with examples:

1. By using Set: It is the simplest approach to remove duplicates. Set is an inbuilt object to store unique values in an array. Here’s how we use set:

    function uniquearray(array) { 
       let unique_array= Array.from(set(array)) 
       return unique_array;}

As in the above code, you created a set of an array which automatically eliminates the duplicate values.

2. By using Filter: Another approach to remove duplicates from an array is applying filter on an array. To call filter method, it requires three arguments: array, current element, index of current element. Here’s how we use filter:

function unque_array (arr){
 let unique_array = arr.filter(function(elem, index, self) {
 return index == self.indexOf(elem); } 
return unique_array }
 console.log(unique_array(array_with_duplicates));

3. By using for loop: In this, we can use for loop to remove duplicates. In this we make an empty array in which those elements will be added from the duplicate array which are not present in this before. Thus, finally we will get an array which has unique elements. Code to implement this:

Array dups_names = ['Ron', 'Pal', 'Fred', 'Rongo', 'Ron'];
function dups_array(dups_names) {
 let unique = {};
 names.forEach(function(i) {
    If (!unique[i]) {
      unique[i] = true;    }
  });
return Object.keys(unique);}   // Ron, Pal, Fred, Rongo
Dups_array(names);

These are the main three methods used in JavaScript to get a unique array.

Question 52. How to call a function in every x seconds in JavaScript?

In JavaScript, we use the function setInterval() to call any function in every x seconds.

Syntax: setInterval(function, milliseconds, param1, param2, …)

Function: it is a required parameter which includes the function to be execute.

Milliseconds: required parameter which tells how often the function will execute.

Others are an additional parameter.

For example: setInterval(function (){ alert(“Hello”); }, 3000);

In the above example, this function calls hello function in very 3 seconds.

Question 53. Explain Promise in JavaScript?

A promise is an object in JavaScript which is used to produce a value that may give result in the future. The value can be resolved value or it can be a reason which tells why the value is not resolved.

A promise can be of three states:

  • Fulfilled: The operation is completed and the promise has a specific value.
  • Rejected: The operation is failed and promise has a reason which shows why the operation failed.
  • Pending: Th operation is not fulfilled or rejected, means it has not completed yet.

Question 54. What is difference between Array.splice() and Array.slice() method in JavaScript?

  • The array.slice() removes items from the array and then return those removed items as an array whereas array.slice() method is selected items from an array and then those elements as a new array object.
  • The splice() method affects the original array whereas slice() method doesn’t affect the original array.
  • Splice() method takes n number of arguments whereas slice() can take only two arguments.

Syntax of splice(): array.splice(index, howmany, item1, ….., itemX)

Syntax of slice(): array.slice(start, end)

Question 55. Is JavaScript multi-threaded or single-threaded?

JavaScript is single-threaded.

Question 56. Explain JavaScript Debounce Function?

Question 57. List some Design patterns in JavaScript?

The design pattern is a general reusable solution to a commonly occurring problem in software design. Some of the design patterns are:

  1. Creational design pattern: These patterns dealt with the mechanism of object creation which optimize object creation with the basic approach.
  2. Structural design pattern: these patterns deal with different classes and objects to provide new functionality.
  3. Behavioral Patterns: These patterns are to improve communication between objects and to recognize patterns.
  4. Concurrency design patterns: These patterns handle with multi-thread programming paradigms.
  5. Architectural design patterns: These patterns used to deal with architectural designs.

Question 58. What is console.time() and console.timeEnd()? What is its syntax, and why is it used?

Question 59. What are different types of Scope Chain available in JavaScript?

If we check in the program, every local scope has a connection with one or more scope in their back which forms a chain. This chain goes on until it met with the global scope which is the root of this hierarchy. As global scope doesn’t have a parent, so it is on the top of the chain. This is known as scope chain.

The scope chain in JavaScript is basically used to resolve the values of the variable. Without this, it is difficult for a JavaScript to choose a certain value for a variable if there are many variables defined at different scopes.

Question 60. How to remove duplicate values from a JavaScript array?

We can use array.indexOf method to check a value exists or not. See below example to remove duplicate values.

let duplicates = [‘delhi’,’kanpur’,’kanpur’,’goa’,’delhi’,’new york’];

function removeDuplicatesValues(arr){
    let unique_array = [];
    for(let i = 0;i < arr.length; i++){
        if(unique_array.indexOf(arr[i]) == -1){
            unique_array.push(arr[i])
        }
    }
    return unique_array
}

console.log(removeDuplicatesValues(duplicates));

Question 61. How to redirect a page to another page in Javascript?

There are several ways to redirect page to another page in JavaScript. These are:

  1. Using location.href: It is the first approach to redirect page. In this, we can go back to access the original document. Syntax:window.location.href =“https://www.onlineinterviewquestions.com/”
  2. Using location.replace: Another approach to redirect page. In this, it is not possible to navigate back to the original document by clicking on the back button as it removes the URL of the original document. Syntax: window.location.replace(” https://www.onlineinterviewquestions.com/;”);

Question 62. Is it possible to do 301 redirects in Javascript ?

JavaScript entirely runs on the client machine. 301 is response code that is sent by the server as a response. So it is not possible to do 301 Redirects In JavaScript.

Question 63. Write a program to reverse a string in pure JavaScript?

There are many ways to reverse a string in JavaScript. These are:

Using in-built functions: the inbuilt function reverse() reverses the string directly. Here’ how:

str="jQuery";
str = str.split(""); //convert 'jQuery' to array
str = str.reverse(); //reverse 'jQuery' order 
str = str.join(""); //then combines  the reverse order values.
alert(str);

First split the string to an array, then reverse an array and after that join the characters to form a string.

Using a loop: First, count a number of characters in a string, then apply a decrementing loop on an original string which starts from the last character and prints each character until count becomes zero.

Question 64. List few Difference between JAVA and JavaScript?

Question 65. Explain MUL function in Javascript?

MUL means simple multiplication of numbers. It is a techique in which you pass a one value as an argument in a function and that function returns another function to which you pass the second value and the process go on. For example: x*y*z can be representing as:

function mul (x) {  
return function (y) { // anonymous function    
return function (z) { // anonymous function      
return x * y * z;    };
  };
}

Question 66. List few advantages of using JavaScript?

Few advantage og Javascript

  • Javascript is executed on user’s computer, the meaning is that whatever you do in Javascript will not add any processing strain on the server. and that’s why it is called as the client-side programming language. And this feature makes your sites responsive for the end user and less expensive for you in terms of server traffic.
  • With the help of Javascript, you can create highly responsive interfaces which will improve the user experience and provide dynamic functionality, without waiting for the server to show another page.
  • If you want to make online systems available offline and sync automatically once the computer goes online, then Javascript is the best technology you can use. you can do this using the right browser add-ons (Such as Google or Yahoo Browser Plus).
  • Content loading and changing it dynamically. Using Ajax in Javascript you can load content into the document if and when the user needs it, without reloading the entire page.
  • Using the Principles of unobtrusive JavaScript(defensive Scripting), JavaScript can test for what is possible in your browser and react accordingly.

Question 67. What is use of settimeout function in JavaScript?

Question 68. What is difference between local and global scope in JavaScript ?

Question 69. What are anonymous functions in JavaScript ?

Question 70. Please explain equality operators in JavaScript?

Question 71. What are the different types of errors available in JavaScript?

There are three types of errors available in JavaScript

  • Load time errors: Errors which come up when loading a web page like improper syntax errors are known as Load-time errors and it generates the errors dynamically.
  • Run time errors: Errors that come due to misuse of the command inside the HTML language.
  • Logical Errors: These are the errors that occur due to the bad logic performed on a function which is having a different operation.
Got a Questions? Share with us