Theme-Logo
  •   .Net
    •   C Sharp(C#)
    •   Web API
    •   Micro Services
    •   ASP.Net
    • ASP.Net MVC
    • .Net Core
  •   Database
    • SQL Server
    • Oracle
    • PostgreSQL
  •   jQuery
    • jQuery Tutorials
    • jQuery Plugins
    • jQuery UI
    • More on jquery
  •   Tutorials
    • Microservices Tutorials
    • DotNet Core Tutorials
    • PostgreSql Tutorials

jQuery Basic Overview

As we know that jQuery is a framework built using JavaScript capabilities. So, we can use all the functions and other capabilities available in JavaScript. In this article it would explain most basic concepts but frequently used in jQuery:

String In jQuery

A string in JavaScript/jQuery is an immutable object that contains none, one or many characters. Following are the valid examples of a JavaScript/jQuery String −

"This is JavaScript/jQuery String"
'This is JavaScript String'
'This is "really" a JavaScript/jQuery String'
"This is 'really' a JavaScript/jQuery String"

Numbers In jQuery

Numbers in JavaScript are double-precision 64-bit format IEEE 754 values. They are immutable, just as strings. Following are the valid examples of a JavaScript/jQuery Numbers −

5350
120.27
0.26

Boolean In jQuery

A boolean in JavaScript/jQuery can be either true or false. If a number is zero, it defaults to false. If an empty string defaults to false Following are the valid examples of a JavaScript Boolean −

                        true      // true
                        false     // false
                        0         // false
                        1         // true
                        ""        // false
                        "hello"   // true

Objects In jQuery

JavaScript/jQuery supports Object concept very well. We can create an object using the object literal as follows −

                            var emp = {
                            name: "Zara",
                            age: 10
                            };

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

Arrays In jQuery

You can define arrays using the array literal as follows −

var x = [];
var y = [1, 2, 3, 4, 5];

An array has a length property that is useful for iteration −

var x = [1, 2, 3, 4, 5];

for (var i = 0; i < x.length; i++) {
   // Do something with x[i]
}

Functions In jQuery

A function in JavaScript can be either named or anonymous. A named function can be defined using function keyword as follows −

function demo(){
   // do some stuff here
}

An anonymous function can be defined in similar way as a normal function but it would not have any name. An anonymous function can be assigned to a variable or passed to a method as shown below.

var handler = function (){
   // do some stuff here
}

Arguments in functions In jQuery

JavaScript variable arguments is a kind of array which has length property. Following example explains it very well −

function func(x){
   console.log(typeof x, arguments.length);
}

func();                //==> "undefined", 0
func(1);               //==> "number", 1
func("1", "2", "3");   //==> "string", 3

Scopes In jQuery

JavaScript have two types of scopes:

  • Global Variables − A global variable has global scope which means it is defined everywhere in your JavaScript/jQuery 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.
  • var myVar = "global";     // ==> Declare a global variable
    
    function ( ) {
       var myVar = "local";   // ==> Declare a local variable
       document.write(myVar); // ==> local
    }

    Note: Within the body of a function, a local variable takes precedence over a global variable with the same name.

    Summary

    To summarise, jQuery is a fast, lightweight, feature-rich client-side which uses JavaScript library. Hope you picked up a thing or two.

    Cheers!

    ❮ Previous
    Next ❯

    Trending Post
    Dependency Injection in C#
    Inversion of controls (IoC)
    Design patterns
    Service-Oriented Architecture(SOA)
    Interview Questions and Answers
    What is Request delegate?
    What is Host in ASP.NET Core?
    Describe the Generic Host and Web Host?
    Describe the Servers in ASP.NET Core?
    How to read values from Appsettings.json file?
    How to handle errors in ASP.NET Core?
    About us

    DotNet Palace is a community platform created and maintained by The articles are mainly focused on Microsoft stack technologies like C#, ASP.Net, MVC, .Net Core, SQL Server and Oracle, PostgreSQL, SQLite etc. To improve the site's content you can send your valuable suggestions at info.dotnetpalace@gmail.com

    Quick links
  • SOLID Principles
  • Questions
  • OOPS Principles
  • DotNet Palace Tutorials
  • Privacy Policy
  • Terms and Condition