December 22, 2018

Srikaanth

Facebook Most Frequently Asked Latest JavaScript Interview Questions Answers

What is the data type of variables of in JavaScript?

All variables in the JavaScript are object data types.

What is the difference between an alert box and a confirmation box?

An alert box displays only one button which is the OK button.

But a Confirmation box displays two buttons namely OK and cancel.

What are escape characters?

Escape characters (Backslash) is used when working with special characters like single quotes, double quotes, apostrophes and ampersands. Place backslash before the characters to make it display.

Example:

document.write "I m a "good" boy"

document.write "I m a \"good\" boy"

What are JavaScript Cookies?

Cookies are the small test files stored in a computer and it gets created when the user visits the websites to store information that they need. Example could be User Name details and shopping cart information from the previous visits.
Facebook Most Frequently Asked Latest JavaScript Interview Questions Answers
Facebook Most Frequently Asked Latest JavaScript Interview Questions Answers

Explain what is pop()method in JavaScript?

The pop() method is similar as the shift() method but the difference is that the Shift method works at the start of the array.  Also the pop() method take the last element off of the given array and returns it. The array on which is called is then altered.
Example:
var cloths = [“Shirt”, “Pant”, “TShirt”];
cloths.pop();
//Now cloth becomes Shirt,Pant

Whether JavaScript has concept level scope?

No. JavaScript does not have concept level scope. The variable declared inside the function has scope inside the function.

Mention what is the disadvantage of using innerHTML in JavaScript?

If you use innerHTML in JavaScript the disadvantage is

Content is replaced everywhere
We cannot use like “appending to innerHTML”
Even if you use +=like “innerHTML = innerHTML + ‘html’” still the old content is replaced by html
The entire innerHTML content is re-parsed and build into elements, therefore its much slower
The innerHTML does not provide validation and therefore we can potentially insert valid and broken HTML in the document and break it

What is break and continue statements?

Break statement exits from the current loop.

Continue statement continues with next statement of the loop.

What are the two basic groups of dataypes in JavaScript?

They are as –

Primitive
Reference types.
Primitive types are number and Boolean data types. Reference types are more complex types like strings and dates.

How generic objects can be created?

Generic objects can be created as:

var I = new object();

What is the use of type of operator?

‘Typeof’ is an operator which is used to return a string description of the type of a variable.

Which keywords are used to handle exceptions?

Try… Catch—finally is used to handle exceptions in the JavaScript


Try{

Code

}

Catch(exp){

Code to throw an exception

}

Finally{

Code runs either it finishes successfully or after catch

}

Which keyword is used to print the text in the screen?

document.write(“Welcome”) is used to print the text – Welcome in the screen.

What is the use of blur function?

Blur function is used to remove the focus from the specified object.

What is variable typing?

Variable typing is used to assign a number to a variable and then assign string to the same variable.

Example is as follows:

i= 8;

i=”john”;

How to find operating system in the client machine using JavaScript?

The ‘Navigator.appversion’ is used to find the name of the operating system in the client machine.

What are the different types of errors in JavaScript?

There are three types of errors:

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 different operation.

What is the difference between the operators '=='  and '==='?

The operator '==' compares the value; whereas, the operator '===' compares both value and type.

What is the difference between null and undefined?

When used the typeof operator on null; i.e., typeof(null), the value is an object. Whereas, when used the typeof operator on undefined; i.e., typeof(undefined), the value would be undefined.

Are Javascript and JScript the same?

No, Javascript was provided by Netscape; whereas, JScript was provided by Microsoft.

What is the use of Push method in JavaScript?

The push method is used to add or append one or more elements to the end of an Array. Using this method, we can append multiple elements by passing multiple arguments

What is unshift method in JavaScript?

Unshift method is like push method which works at the beginning of the array.  This method is used to prepend one or more elements to the beginning of the array.

What is the difference between JavaScript and Jscript?

Both are almost similar. JavaScript is developed by Netscape and Jscript was developed by Microsoft .
How are object properties assigned?

Properties are assigned to objects in the following way –

obj["class"] = 12;
or

obj.class = 12;

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

Strict Mode adds certain compulsions to JavaScript. Under the strict mode, JavaScript shows errors for a piece of codes, which did not show an error before, but might be problematic and potentially unsafe. Strict mode also solves some mistakes that hamper the JavaScript engines to work efficiently.

Strict mode can be enabled by adding the string literal “use strict” above the file. This can be illustrated by the given example:

function myfunction()

{

“use strict";

var v = “This is a strict mode function";

}

Subscribe to get more Posts :