Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jquery is nothing like javascript

Featured Replies

jQuery is a Javascript library. It uses javascript but is designed to make using javascript much easier to use.

 

There are tons of tutorials about it here

Edited by itodd

In JavaScript, functions may have names, or they may not. Functions without names are known as "anonymous". There's no performance benefit one way or another. Named functions make it a lot easier to reference the function while inside it (such as a recursive function) but require a little more typing.

 

Here's a named function:

function deleteOne(start) {
   if (start < 0 || typeof(start) !== "number") {
       throw "Well this isn't going to work...";
   } else if (start === 0) {
       alert("We've hit 0!");
   } else {
       // In this function, we can use 'deleteOne' to reference itself.
       deleteOne(start - 1);
   }
}

It's also possible to to put store named functions in a variable, as a property or pass them to a function:

// This named function is stored in a variable.
// They can have different names, or the same.
var myFunc = function myFunc(foo) {
   // Here "myFunc" refers to this function.
};

// Same as above, but with a different name.
var myFunc = function myNamedFunc(foo) {
   // Here "myNamedFunc" refers to this function.
   // "myFunc" is the variable. It refers to the same function as "myNamedFunc"
   // but is in a higher scope, so is slightly slower to resolve than "myNamedFunc"
};

// Here is an object literal
var myObj = {
   // This has the same rules as the named function above.
   foo: function bar() {
   }
};

// Here we pass a named function to another function.
myFunc(function fooBar() {
   alert('FOOBAR!');
});

 

Anonymous functions simply don't have the name. It's harder to refer to these functions within themselves, but if you're not recursing, this isn't a problem.

// Here's a function stored in a variable.
var myFunction = function () {
   alert('Fear us for we are Anonymous!');
};

// Here is an object literal
var myObj = {
   foo: function () {
   }
};

// Here the function is being passed to another function
myFunction(function () {
   alert('Totally anonymous');
});

Anonymous functions have one useful bonus. You often see JavaScript libraries wrapped in this pattern:

 

(function () {
   // This is a self-executing anonymous function. It has a few advantages a magic powers,
   // The main thing it does it contain the scope so the global scope isn't flooded. In here
   // all variables declared in here don't exist outside this function.
   // Frequently short-cuts to window, document and undefined are passed as arguments.
}());

 

Does that help answer your question?

Edited by Skateside

  • Author

In JavaScript, functions may have names, or they may not. Functions without names are known as "anonymous". There's no performance benefit one way or another. Named functions make it a lot easier to reference the function while inside it (such as a recursive function) but require a little more typing.

 

Here's a named function:

function deleteOne(start) {
   if (start < 0 || typeof(start) !== "number") {
       throw "Well this isn't going to work...";
   } else if (start === 0) {
       alert("We've hit 0!");
   } else {
       // In this function, we can use 'deleteOne' to reference itself.
       deleteOne(start - 1);
   }
}

It's also possible to to put store named functions in a variable, as a property or pass them to a function:

// This named function is stored in a variable.
// They can have different names, or the same.
var myFunc = function myFunc(foo) {
   // Here "myFunc" refers to this function.
};

// Same as above, but with a different name.
var myFunc = function myNamedFunc(foo) {
   // Here "myNamedFunc" refers to this function.
   // "myFunc" is the variable. It refers to the same function as "myNamedFunc"
   // but is in a higher scope, so is slightly slower to resolve than "myNamedFunc"
};

// Here is an object literal
var myObj = {
   // This has the same rules as the named function above.
   foo: function bar() {
   }
};

// Here we pass a named function to another function.
myFunc(function fooBar() {
   alert('FOOBAR!');
});

 

Anonymous functions simply don't have the name. It's harder to refer to these functions within themselves, but if you're not recursing, this isn't a problem.

// Here's a function stored in a variable.
var myFunction = function () {
   alert('Fear us for we are Anonymous!');
};

// Here is an object literal
var myObj = {
   foo: function () {
   }
};

// Here the function is being passed to another function
myFunction(function () {
   alert('Totally anonymous');
});

Anonymous functions have one useful bonus. You often see JavaScript libraries wrapped in this pattern:

 

(function () {
   // This is a self-executing anonymous function. It has a few advantages a magic powers,
   // The main thing it does it contain the scope so the global scope isn't flooded. In here
   // all variables declared in here don't exist outside this function.
   // Frequently short-cuts to window, document and undefined are passed as arguments.
}());

 

Does that help answer your question?

 

Yes thanks to a certain.Its when theyre being used in jQUERY is where im referring to, so your explanation at the end is great.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.