Java Script Interview QUESTIONS

Exam NameJava Script Interview QUESTIONS
DescriptionJava Script Interview QUESTIONS contains the questions from various interview of IT industry.These questions are helpful to crack the IT interview.

Back to Parent Category
Create QuestionPDF  
Question: Is jQuery replacement of Java Script?

Answer:No. jQuery is not a replacement of JavaScript. jQuery is a different library which is written on top of JavaScript. jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML.

Question: What is jQuery?

Answer:jQuery is fast, lightweight and feature-rich client side JavaScript Library/Framework which helps in to traverse HTML DOM, make animations, add Ajax interaction, manipulate the page content, change the style and provide cool UI effect. It is one of the most popular client side library and as per a survey it runs on every second website.

Question: How do you implement animation functionality?

Answer:The .animate() method allows us to create animation effects on any numeric CSS property. This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually, to create an animated effect.


  • styles: Specifies one or more CSS properties/values to animate.
  • duration: Optional. Specifies the speed of the animation.
  • easing: Optional. Specifies the speed of the element in different points of the animation. Default value is "swing".
  • callback: Optional. A function to be executed after the animation completes.


  • Question: What are selectors in jQuery and how many types of selectors are there?

    Answer:To work with an element on the web page, first we need to find them. To find the html element in jQuery we use selectors. There are many types of selectors but basic selectors are:

  • Name: Selects all elements which match with the given element Name.
  • #ID: Selects a single element which matches with the given ID
  • .Class: Selects all elements which match with the given Class.
  • Universal (*): Selects all elements available in a DOM.
  • Multiple Elements E, F, G: Selects the combined results of all the specified selectors E, F or G.
  • Attribute Selector: Select elements based on its attribute value.

  • Question: How to disable jQuery animation?

    Answer:Using jQuery property "", which when set to true, disables all the jQuery animation. When this is done, all animation methods will immediately set elements to their final state when called, rather than displaying an effect.

    Question: Is jQuery a W3C standard?

    Answer:No. jQuery is not a W3C standard.

    Question: How do you attach a event to element which should be executed only once?

    Answer:Using jQuery one() method. This attaches a handler to an event for the element. The handler is executed at most once per element. In simple terms, the attached function will be called only once.
    $(document).ready(function() {
    $("#btnDummy").one("click", function() {
    alert("This will be displayed only once.");

    Question: How to create clone of any object using jQuery?

    return false;

    Question: Which is fast document.getElementByID('txtName') or $('#txtName').?

    Answer:Native JavaScipt is always fast. jQuery method to select txtName "$('#txtName')" will internally makes a call to document.getElementByID('txtName'). As jQuery is written on top of JavaScript and it internally uses JavaScript only So JavaScript is always fast.

    Question: How do you check if an element is empty?

    Answer:There are 2 ways to check if element is empty or not. We can check using ":empty" selector.

    if ($('#element').is(':empty')){
    //Element is empty

    And the second way is using the "$.trim()" method.

    if($.trim($('#element').html())=='') {
    //Element is empty

    Question: What is CDN?

    Answer: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.

    Question: What does dollar sign ($) means in jQuery?

    Answer:Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code.


    Over here $ sign can be replaced with "jQuery" keyword.


    Question: How can we debug jQuery?

    Answer:There are two ways to debug jQuery:

    Debugger keyword

    Add the debugger to the line from where we have to start debugging and then run Visual Studio in Debug mode with F5 function key.

    Insert a break point after attaching the process

    Question: Can we have multiple document.ready() function on the same page?

    Answer:YES. We can have any number of document.ready() function on the same page.

    Question: How do you check if an element exists or not in jQuery?

    if ($('#element').length > 0){
    //Element exists

    Question: Difference between $(this) and 'this' in jQuery?

    Answer:this and $(this) refers to the same element. The only difference is the way they are used. 'this' is used in traditional sense, when 'this' is wrapped in $() then it becomes a jQuery object and you are able to use the power of jQuery.


    In below example, this is an object but since it is not wrapped in $(), we can't use jQuery method and use the native JavaScript to get the value of span element.


    Question: Why there are two different version of jQuery library?

    Answer:jQuery library comes in 2 different versions.

  • Development
  • Production/Deployment

    The development version is quite useful at development time as jQuery is open source and if you want to change something then you can make those changes in development version. But the deployment/production version is minified version or compressed version so it is impossible to make changes in it(compress by removing all white spaces and reducing the size of vaiable names). Because it is compressed, so its size is very less than the development version which affects the page load time.