From the course: jQuery: Creating Plugins

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Adding more-powerful options using functions

Adding more-powerful options using functions - jQuery Tutorial

From the course: jQuery: Creating Plugins

Start my 1-month free trial

Adding more-powerful options using functions

- One of the aspects of JavaScript that's pretty interesting, and not necessarily as well-known to beginning programmers, is that JavaScript is a functional language. When I say a functional language, that means that functions themselves, these procedures that we bundle up and call functions, can be passed around like any other variable. So, how might we use that in a jQuery plugin? Looking at this example in Chapter_04, folder 04_01, the start, the index.html file. This is the ads example from the challenge in the last chapter. And remember that you need to load this in Safari on the Mac or Internet Explorer on Windows for it to work right on the file system without a local web server. So looking at these ads over here, before, we defined the ad source as a static array. Let's look at another way that we can handle this using a function instead of a static array. So here in the html file, this is what I'm talking about. Here are the options, just like they were before, as far as…

Contents