Interview Question For Javascript: Most Asked Question In Interview

0
4292
Interview Question For Javascript
Interview Question For Javascript

Interview Question For Javascript: Most Asked Question In Interview

Interview Question For JavaScript: Set 1

1. What is JavaScript?

JavaScript is a client-side as well as server side scripting language that can be inserted into HTML pages and is understood by web browsers. JavaScript is also an Object based Programming language.

2. What are the major differences between Java and JavaScript?

Java is a complete programming language. In contrast, JavaScript is a coded program that can be introduced to HTML pages. These two languages are not at all inter-dependent and are designed for the different intent. Java is an object – oriented programming (OOPS) or structured programming language like C++ or C whereas JavaScript is a client-side scripting language.

3. What Kind Of Data Types Used In JavaScript ?

Following are the JavaScript Data types:

  • Number
  • String
  • Boolean
  • Object
  • Undefined

4. What is the use of isNaN function?

isNan function returns true if the argument is not a number otherwise it is false.

5. What is difference between JavaScript and an ASP script, which is faster?

JavaScript is faster. JavaScript is a client-side language and thus it does not need the assistance of the web server to execute. On the other hand, ASP is a server-side language and hence is always slower than JavaScript.

6. Which company developed JavaScript?

Netscape is the software company who developed JavaScript.

7. What is a prompt box?

A prompt box is a box which allows the user to enter input by providing a text box. Label and box will be provided to enter the text or number.

8. Does JavaScript support automatic type conversion?

Yes JavaScript does support automatic type conversion, it is the common way of type conversion used by JavaScript developers.

9. What are the scopes of a variable in JavaScript?

  • The scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes.
  • Global Variables − A global variable has global scope which means it is visible everywhere in your JavaScript code.
  • Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.

10.What is the purpose of ‘This’ operator in JavaScript?

The JavaScript this keyword refers to the object it belongs to. This has different values depending on where it is used. In a method, this refers to the owner object and in a function, this refers to the global object.

11. Explain how to read and write a file using JavaScript?

There are two ways to read and write a file using JavaScript

  • Using JavaScript extensions
  • Using a web page and Active X objects

12. Explain the difference between “==” and “===”?

“==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different.

13. What is Closure? Give an example.

Closures are created whenever a variable that is defined outside the current scope is accessed from within some inner scope. It gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created. To use a closure, simply define a function inside another function and expose it.

14. How does TypeOf Operator work?

The typeof operator is used to get the data type of its operand. The operand can be either a literal or a data structure such as a variable, a function, or an object. It is a unary operator that is placed before its single operand, which can be of any type. Its value is a string indicating the data type of the operand.

15. How to create a cookie using JavaScript?

The simplest way to create a cookie is to assign a string value to the document.cookie object, which looks like this-

document.cookie=”key1 = value1; key2 = value2; expires = date”;

16. What are the ways to define a variable in JavaScript?

The three possible ways of defining a variable in JavaScript are:

  • Var – The JavaScript variables statement is used to declare a variable and, optionally, we can initialize the value of that variable. Example: var a =10; Variable declarations are processed before the execution of the code.
  • Const – The idea of const functions is not allow them to modify the object on which they are called. When a function is declared as const, it can be called on any type of object.
  • Let – It is a signal that the variable may be reassigned, such as a counter in a loop, or a value swap in an algorithm. It also signals that the variable will be used only in the block it’s defined in.

17. What are advantages of JavaScript.

Some of the advantages of JavaScript are:

  • Server interaction is less
  • Feedback to the visitors is immediate
  • Interactivity is high
  • Interfaces are richer

18. What are disadvantages of JavaScript.

Some of the disadvantages of JavaScript are:

No support for multithreading
No support for multiprocessing
Reading and writing of files is not allowed
No support for networking applications.

19. How to use external JavaScript file?

I am assuming that js file name is message.js, place the following script tag inside the head tag.

20. Is JavaScript case sensitive language?

Yes, JavaScript is a case sensitive language. For example:

Var msg = "JavaScript is a case-sensitive language"; //Here, var should be used to declare a variable
function display()
{
document.writeln(msg); // It will not display the result.
}
display()
;

21. What is BOM?

BOM stands for Browser Object Model. It provides interaction with the browser. The default object of a browser is a window. So, you can call all the functions of the window by specifying the window or directly. The window object provides various properties like document, history, screen, navigator, location, innerHeight, innerWidth. This is Most Asked Interview Question For Javascript.

22. What is the use of history object?

The history object of a browser can be used to switch to history pages such as back and forward from the current page or another page. There are three methods of history object.

  • history.back() – It loads the previous page.
  • history.forward() – It loads the next page.
  • history.go(number) – The number may be positive for forward, negative for backward. It loads the given page number.

23. How to write a comment in JavaScript?

There are two types of comments in JavaScript.

Single Line Comment: It is represented by // (double forward slash)
Multi-Line Comment: Slash represents it with asterisk symbol as /* write comment here */

24. In which location cookies are stored on the hard disk?

The storage of cookies on the hard disk depends on the OS and the browser.

The Netscape Navigator on Windows uses a cookies.txt file that contains all the cookies. The path is c:\Program Files\Netscape\Users\username\cookies.txt

The Internet Explorer stores the cookies on a file [email protected] The path is: c:\Windows\Cookies\[email protected]

25. What is the real name of JavaScript?

The original name was Mocha, a name chosen by Marc Andreessen, founder of Netscape. In September of 1995, the name was changed to LiveScript. In December 1995, after receiving a trademark license from Sun, the name JavaScript was adopted. This is Most Asked Interview Question For Javascript

If You Want To Get More Daily Such Interview Questions Updates Then Press Red Bell Icon At The Right Side of Page To Subscribe our Updates.

Looking For High Paying Jobs: Click here

Also Read:Interview Question In HR Interview: Click here

Join Whatsapp Group of Daily Jobs Updates for 2010-2020 Batch: Click Here

Subscribe Our Telegram Channel for Interview Questions: Click here

Also Read: Daily Morning Skin Care For Glowing Skin: Click here

Also Read:How To Get a Job Easily: Professional Advice For Job Seekers: Click here

LEAVE A REPLY

Please enter your comment!
Please enter your name here