1.What is jQuery?
jQuery is a fast and concise JavaScript Library created by John Resig in 2006 with a nice motto – Write less, do more. jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is a JavaScript toolkit designed to simplify various tasks by writing less code.
2.What are the core features of jQuery?
Following is the list of important core features supported by jQuery −
DOM manipulation − The jQuery made it easy to select DOM elements, traverse them and modifying their content by using cross-browser open source selector engine called Sizzle.
Event handling − The jQuery offers an elegant way to capture a wide variety of events, such as a user clicking on a link, without the need to clutter the HTML code itself with event handlers.
AJAX Support − The jQuery helps you a lot to develop a responsive and feature-rich site using AJAX technology.
Animations − The jQuery comes with plenty of built-in animation effects which you can use in your websites.
Lightweight − The jQuery is very lightweight library – about 19KB in size ( Minified and gzipped ).
Cross Browser Support − The jQuery has cross-browser support, and works well in IE 6.0+, FF 2.0+, Safari 3.0+, Chrome and Opera 9.0+.
Latest Technology − The jQuery supports CSS3 selectors and basic XPath syntax.
3.How will you make sure that DOM is ready using jQuery?
Use $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded.
4.How can you create an Object in JavaScript?
JavaScript supports Object concept very well. You can create an object using the object literal as follows −
var emp = {
name: “Zara”,
age: 10
};
5.How can you read properties of an Object in JavaScript?
You can write and read properties of an object using the dot notation as follows −
// Getting object properties
emp.name // ==> Zara
emp.age // ==> 10
// Setting object properties
emp.name = “Daisy” // <== Daisy
emp.age = 20 // <== 20
6.How can you create an Array in JavaScript?
You can define arrays using the array literal as follows −
var x = [];
var y = [1, 2, 3, 4, 5];
7.How to read elements of an array in JavaScript?
An array has a length property that is useful for iteration. We can read elements of an array as follows −
var x = [1, 2, 3, 4, 5];
for (var i = 0; i < x.length; i++) {
// Do something with x[i]
}
8.What is a named function in JavaScript? How to define a named function?
A named function has a name when it is defined. A named function can be defined using function keyword as follows −
function named(){
// do some stuff here
}
9.How many types of functions JavaScript supports?
A function in JavaScript can be either named or anonymous.
10.How to define a anonymous function?
An anonymous function can be defined in similar way as a normal function but it would not have any name.