JQuery Importent Interview Questions with Answers


What is jQuery?

Ø  jQuery is a JavaScript library that simplifies JavaScript and AJAX programming. JavaScript is used to add interactivity and dynamic content to web pages. AJAX (Asynchronous JavaScript and XML) is used for handling external data asynchronously through JavaScript, without refreshing the whole page.
Ø  jQuery emphasizes the interaction between JavaScript and HTML. jQuery contains all the common DOM, event, effects, and Ajax functions in a single JavaScript file.
Ø  The jQuery file needs to be included in the file which is going to use the jQuery functionality.
Ø  jQuery provides a new class called jQuery without extending the built-in JavScript classes which acts as a wrapper around objects for providing them the extended operations.

Advantages of jQuery

The advantages of using jQuery are:
Ø JavaScript enhancement without the overhead of learning new syntax
Ø Ability to keep the code simple, clear, readable and reusable
Ø Eradication of the requirement of writing repetitious and complex loops and DOM scripting library calls

Explain the features of jQuery.

Features of jQuery are :
Ø Effects and animations
Ø Ajax
Ø Extensibility
Ø DOM element selections functions
Ø Events
Ø CSS manipulation
Ø Utilities - such as browser version and the each function.
Ø JavaScript Plugins
Ø DOM traversal and modification.

Explain the concepts of "$ function" in jQuery with an example.

                The type of a function is "function".
                There are a lot of anonymous functions is jquery.
                $(document).ready(function() {});
                $("a").click(function() {});

                $.ajax({
                                url: "someurl.php",
                                 success: function() {}
                });

Why is jQuery better than javascript?

Ø jQuery is great library for developing ajax based application.
Ø It helps the programmers to keep code simple and concise and reusable.
Ø jQuery library simplifies the process of traversal of HTML DOM tree.
Ø jQuery can also handle events, perform animation, and add the ajax support in web applications.

Explain how jQuery Works.

                <html>
                <head>
                                <script type="text/javascript" src="jquery.js"></script>
                                <script type="text/javascript">
                                 // You can write the code here
                                </script>
                </head>
                <body>
                                 <a href="http://careerride.com/">CareerRide</a>
                </body>
                </html>

When can you use jQuery?

                jQuery can be used to for developing ajax based applications
                It can be used to keep the code simple, concise and reusable.
                It simplifies the process of traversal of HTML DOM tree.
                It can also handle events, perform animation, and add the ajax support in web applications.
What does dollar sign($) means in Jquery?
                Dollar sign is nothing but it's an alias for Jquery. Take a look at below jquery code
                               
                $(document).ready(function(){

                });
                Over here $ sign can be replaced with "jQuery " keyword.
                                jQuery(document).ready(function(){
                                });
How is body onload() function is defferent from document.ready() functon used in  Jquery?
                Document.ready() function is different from body onload() function because off 2 reasons.

                1.  We can have more than one document.ready() function in a page where we can have only one                 onload function.
                2. Document.ready() function is called as soon as DOM is loaded where body.onload() function                                 is called when everything gets loaded on the page that includes DOM, images and all                                         associated resources of the page.

What is Jquery UI?
                JQuery UI is a library which is built on top of JQuery library. JQuery UI comes with cool    widgets, effects and interaction mechanism.

                See below page on this site. Date Picker control used in this page to select date is an example of              JQuery UI.
Name some of the methods of Jquery used to provide effects?
                Some of the common methods are :

                                1. Show()
                                2. Hide()
                                3. Toggle()
                                4. FadeIn()
                                5. FadeOut()
what are the different type of selectors in Jquery?

                There are 3 types of selectors in Jquery
                                1. CSS Selector
                                2. XPath Selector
                                3. Custom Selector

How can you select all elements in a page using Jquery?

                <script language="javascript" type="text/javascript">
                        $("*").css("border", "2px dotted red");
                </script>

How can you select all elements in a page using jQuery?


                To select all elements in a page, we can use all selectors, for that we need to use *(asterisk         symbol).
                <script language="javascript" type="text/javascript">
                       $("*").css("border", "2px dotted red");
                </script>

The above code will select all elements of the web page and apply border width as 2 pixel, style as dotted and color as red.

What is the Difference between Jquery-X.X.X.js and Jquery.X.X.X-min.js?
In terms of functionality, there is no difference between the jQuery-x.x.x.js and jQuery-x.x.x-min.js (also called minified version). However this can play a vital role in the performance of the web page.

How it affects the performance?
jQuery-1.4.4.js file size is 178 KB as against its minified version jQuery-1.4.4-min.js that is only 76.7 KB in size. So when your page loads in the client?s browser if you are not using minified version, it loads 178 KB file that takes more time to load than 76.7 KB.

What is CDN?
CDN Stands for Content Distribution Network or also called Content Delivery Network is a group of computers placed at various points connected with network containing copies of data files to maximize bandwidth in accessing the data. In CDN a client access a copy of data nearer to the client location rather than all clients accessing
from the one particular server. This helps to achieve better performance of data retrieval by client.

There are two leading CDNs available that hosts jQuery files.

Microsoft - To load jQuery from Microsoft AJAX CDN
jQuery file can be loaded from Microsoft AJAX CDN. For more details, go to http://www.asp.net/ajaxlibrary/cdn.ashx. You will need to keep following tags in your page.

<script type="text/javascript" language="Javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.1.min.js"></script>
Google - To load jQuery from Google Libraries API

jQuery file can be loaded from Google CDN for more details, go to http://code.google.com/apis/libraries/devguide.html. You will need to keep following tag in your page.
<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
What’s relationship between JavaScript and ECMAScript? - ECMAScript is yet another name for

JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

What are JavaScript types?

Number, String, Boolean, Function, Object, Null, Undefined.

How do you convert numbers between different bases in JavaScript?

Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);

What does isNaN function do?
Return true if the argument is not a number.

What is negative infinity?
It’s a number in JavaScript, derived by dividing negative number by zero.

What boolean operators does JavaScript support?
&&, || and !

What does "1"+2+4 evaluate to?

Since 1 is a string, everything is a string, so the result is 124.

How about 2+5+"8"?

Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result.

What looping structures are there in JavaScript?

 for, while, do-while loops, but no foreach.

How do you create a new object in JavaScript?

var obj = new Object(); or var obj = {};
How do you assign object properties?

obj["age"] = 17 or obj.age = 17.

What’s a way to append a value to an array?

arr[arr.length] = value;

What is this keyword?
 It refers to the current object.
Is jQuery a library for client scripting or server scripting?

 Client scripting

Is jQuery a W3C standard?
No

What are jQuery Selectors?

Selectors are used in jQuery to find out DOM elements. Selectors can find the elements via ID, CSS, Element name and hierarchical position of the element.

The jQuery html() method works for both HTML and XML documents?

It only works for HTML.

Which sign does jQuery use as a shortcut for jQuery?

 $(dollar) sign.

What does $("div") will select?

 It will select all the div element in the page.

What does $("div.parent") will select?

 All the div element with parent class.

What is the name of jQuery method used for an asynchronous HTTP request?

jQuery.ajax() 

4 comments:

  1. Nice one. Thanks for the share. Keep posting such kind of information on your blog. I bookmarked it for continuous visit.
    html5 player

    ReplyDelete
    Replies
    1. Thank you for visiting my blog. I will post data which is useful to IT people.

      Delete
  2. Thank you for visiting my blog. I will post data which is useful to IT people.

    ReplyDelete