Covid-19 Update!!    We have enabled all courses through virtual classroom facility using Skype or Zoom.    Don't stop learning.    Enjoy Learning from Home.

30% Discount Python        30% Discount Webdesign        30% Discount SEO        30% Discount Angular8        Free SQL Class        Free Agile Workshop       Free HTML Sessions        Free Python Basics

Important Javascript Interview Questions and Answers

JavaScript Interview Questions

1. What is JavaScript?

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

2. Enumerate the differences between Java and JavaScript?

The following are the difference:

* Java is a complete programming language but JavaScript is a coded program that can be introduced to HTML pages.
* Java and JavaScript are not inter-dependent and are designed for the different intent.
* Java is an object – related programming (OOPS) or structured programming language but JavaScript is a client-side scripting language.

3. What are JavaScript Data Types?

Following are the JavaScript Data types:

  • Number
  • String
  • Boolean
  • Function
  • 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. Explain what is Information Architecture?

    A number in JavaScript which can be obtained by dividing negative number by zero is Negative Infinity.

    6. Which company developed JavaScript?

    Netscape is the software company who developed JavaScript.

    7. What are undeclared and undefined variables?

    Undeclared variables are those that do not prevail in a program and are undeclared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.
    Undefined variables are those that are mentioned in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.

    8. What are global variables? How are these variable declared and what are the problems associated with using them?

    Global variables are those that are available around the length of the code, that is, these have no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared.
    Example:
    // declare a global globalVariable = “Test”;
    The problems that are faced by using global variables are the clash of variable names of local and global scope. Also, it is difficult to debug and test the code that relies on global variables.

    9. What is a prompt box?

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

    10. What is ‘this’ keyword in JavaScript?

    ‘This’ keyword refers to the object from where it was called.

    11. Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

    To perform a piece of code at a set time or also to repeat the code in a given interval of time, timers are used. By using the setTimeout, setInterval and clearInterval functions
    The setTimeout(function, delay) is used to start a timer that calls a specific function after the mentioned delay and repeatedly perform the given function in the mentioned delay and only halts when cancelled. To control timer to stop clearInterval(id) function is supported.
    The drawback of Timers are operated within a single thread by this the events might queue up, waiting to be performed.

    12. What is the difference between ViewState and SessionState?

    The difference between ‘ViewState’ and ‘SessionState’, ‘ViewState’ is particular to a page in a session. Whereas, ‘SessionState’ is specific to user on particular data that can be accessed across all pages in the web application.

    13. Explain how can you submit a form using JavaScript?

    To submit a form using JavaScript use document.form[0].submit();
    document.form[0].submit();

    14. 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
  • 15. Explain how to detect the operating system on the client machine?

    The navigator.appVersion string (property) will help to detect the operating system on the client machine.

    16. What do mean by NULL in Javascript?

    The NULL value is used to represent no value, object, null string, valid boolean value, number and no array object.

    17. What is the function of delete operator?

    To delete all variables and objects in a program but it cannot delete variables declared with VAR keyword the delete operator is used.

    18. What is the use of Void(0)?

    The uses of Void(0) are:

    * Void will secure the page from refreshing
    * limitation “zero” is passed while calling.
    * Void(0) calls in another method without refreshing the page.

    19. Explain what is pop()method in JavaScript?

    The pop() method is same as the shift() method. The few differences are:
    the Shift() method works at the start of the array but the pop() method take the last element off of the given array and returns it.
    Example:
    var cloths = [“Shirt”, “Pant”, “TShirt”];
    cloths.pop();
    //Now cloth becomes Shirt,Pant

    20. Mention what is the disadvantage of using innerHTML in JavaScript?

    The disadvantage of innerHTML in JavaScript are:-
    Content is replaced everywhere
    We cannot operate like “appending to innerHTML”
    Even if you work +=like “innerHTML = innerHTML + ‘html’” still the old content is exchanged by html
    The entire innerHTML content is re-parsed and build into elements, therefore its much slower
    The innerHTML does not produce certification and therefore we can probably insert valid and broken HTML in the document.