October 11, 2018

Sreekanth B

Genpact JavaScript Most Frequently Asked Latest Interview Questions Answers

What is the way to get the status of a CheckBox?

The status can be acquired as follows –


If the CheckBox will be checked, this alert will return TRUE.

How can the OS of the client machine be detected?

The navigator.appVersion string can be used to detect the operating system on the client machine.

Explain window.onload and onDocumentReady?

The onload function is not run until all the information on the page is loaded. This leads to a substantial delay before any code is executed.

onDocumentReady loads the code just after the DOM is loaded. This allows early manipulation of the code.
Genpact JavaScript Most Frequently Asked Latest Interview Questions Answers
Genpact JavaScript Most Frequently Asked Latest Interview Questions Answers

How will you explain closures in JavaScript? When are they used?

Closure is a locally declared variable related to a function which stays in memory when the function has returned.

For example:

function greet(message) {



function greeter(name, age) {

return name + " says howdy!! He is " + age + " years old";


// Generate the message

var message = greeter("James", 23);

// Pass it explicitly to greet


This function can be better represented by using closures

function greeter(name, age) {

var message = name + " says howdy!! He is " + age + " years old";

return function greet() {




// Generate the closure

var JamesGreeter = greeter("James", 23);

// Use the closure


How can a value be appended to an array?

A value can be appended to an array in the given manner –

arr[arr.length] = value;

Explain the for-in loop?

The for-in loop is used to loop through the properties of an object.

The syntax for the for-in loop is –

for (variable name in object){

statement or block to execute

In each repetition, one property from the object is associated to the variable name, and the loop is continued till all the properties of the object are depleted.

Describe the properties of an anonymous function in JavaScript?

A function that is declared without any named identifier is known as an anonymous function. In general, an anonymous function is inaccessible after its declaration.

Anonymous function declaration –

var anon = function() {

alert('I am anonymous');



What is the difference between .call() and .apply()?

The function .call() and .apply() are very similar in their usage except a little difference. .call() is used when the number of the function’s arguments are known to the programmer, as they have to be mentioned as arguments in the call statement. On the other hand, .apply() is used when the number is not known. The function .apply() expects the argument to be an array.

The basic difference between .call() and .apply() is in the way arguments are passed to the function. Their usage can be illustrated by the given example.

var someObject = {

myProperty : 'Foo',

myMethod : function(prefix, postfix) {

alert(prefix + this.myProperty + postfix);



someObject.myMethod('<', '>'); // alerts '<Foo>'

var someOtherObject  = {

myProperty : 'Bar'


someObject.myMethod.call(someOtherObject, '<', '>'); // alerts '<Bar>'

someObject.myMethod.apply(someOtherObject, ['<', '>']); // alerts '<Bar>'

Define event bubbling?

JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of parent will also work as if it were clicked too.

Is JavaScript case sensitive? Give an example?

Yes, JavaScript is case sensitive. For example, a function parseInt is not same as the function Parseint.

What boolean operators can be used in JavaScript?

The ‘And’ Operator (&&), ‘Or’  Operator (||) and the ‘Not’ Operator (!) can be used in JavaScript.

*Operators are without the parenthesis.

How can a particular frame be targeted, from a hyperlink, in JavaScript?

This can be done by including the name of the required frame in the hyperlink using the ‘target’ attribute.

<a href=”newpage.htm” target=”newframe”>>New Page</a>

What is the use jQuery.data method?

jQuery.data methods is used to associate the data with the DOM nodes and the objects. This data method makes the jQuery code clear and concise.

What is the use of each function in jQuery?

Each function is used to iterate each and every element of an object. It is used to loop DOM elements, arrays and the object properties.

What is the difference between size and length of jQuery?

Size and length both returns the number of element in an object. But length is faster than the size because length is a property and size is a method.

Can we add more than one ‘document.ready’ function in a page?

Yes, we can add more than one document.ready function in a page. But, body.onload can be added once in a page.

What is the use of jQuery load method?

jQuery load method is a powerful AJAX method which is used to load the data from a server and assign the data into the element without loading the page.

Whether our own specific characters are used in place of $ in jQuery?

Yes, We can use our own variable in place of $ by using the method called no Conflict () method.

var sample = $.noConflict()

What are the four parameters used for jQuery Ajax method?

The four parameters are

URL – Need to specify the URL to send the request
type – Specifies type of request(Get or Post)
data – Specifies data to be sent to server
Cache – Whether the browser should cache the requested page

What is the use of jQuery filter?

The jQuery filter is used to filter the certain values from the object list based on the criteria. Example is to filter certain products from the master list of products in a cart website.

Which program is useful for testing jQuery?

QUnit is used to test jQuery and it is very easy and efficient.

What is CDN?

CDN is abbreviated as Content Distribution network and it is said to be a group of companies in different location with network containing copies of data files to maximize bandwidth in accessing the data.

What are the two types of CDNs?

There are two types of CDNs:

Microsoft – Load jQuery from Ajax CDN
Google – Load jQuery from Google libraries API

Which sign is used as a shortcut for jQuery?

Dollar ($) sign is used as a shortcut for jQuery.

Is jQuery is a client or server scripting?

jQuery is a client scripting.

What is the script build up by jQuery?

jQuery is a Javascript file and it is single javascript file that contains common DOM, event effects and Ajax functions.

Subscribe to get more Posts :