Skip to navigation | Skip to content

Share your knowledge. Make a difference.

JavaScript Programming

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic (by 0 people)   Your rating: 1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic

Ranked #2947 in Tech

0 people favorited this page (yet!)

Rated G. (Control what you see)

Created by LeckyT

Author of Just Enough Web Programming, and countless articles on programming, my lenses reflect the need for every computer user to start learning pro...  (more...)

Start your own Squidoo page

Your fans are waiting!

Learn JavaScript Programming from a Programmer!

 

The best way to learn is by doing - and making mistakes! - Up to a point, yes.

Before you rush off and copy free JavaScript applications into your web pages, it is a good idea to know what you are doing. This lens is dedicated to providing a JavaScript course that will get the reader started in double-quick time!

From the author of Just Enough Web Programming, a series of links to help you on your way ... and keep you coming back!

Applied JavaScript Programming 

For those of you who know a little JavaScript, here are some articles that show you what people are doing with it!


(For those who don't, keep going - all will be revealed...)
Beginning AJAX and Web XML: A Pragmatic Primer for Professional Web Developers
AJAX and XML for Web Developers explained in a pragmatic primer for beginning and experienced professional web developers.
JavaScript AJAX Dynamic PHP HTML: Using AJAX and PHP to Create Page Content Linked to Keywords in URL
Article describing how AJAX and PHP can be used to dynamically populate HTML containers referencing content from the URL and page itself.
JavaScript Randomize Landing Page: Illustration of JavaScript Arrays, HTTP Redirection and Math.random
JavaScript tutorial article showing how to set up an array, select an item at random, and use it to redirect the browser to one of a collection of possible landing pages.

What is JavaScript? 

JavaScript is a client side scripting language which allows the programmer to add logic to their web pages.

That's the technical answer, anyway, but you don't want to know that, do you? What you want to know is - what can JavaScript do for me?

The answer is pretty easy : you can use it to make your site more sticky, more user friendly, and more worthwhile. Plus, it'll probably make you more money - if you're selling things, that is.

JavaScript helps you add a shopping cart. It'll help you add nice user interfaces to your pages. You can use it to make fun questionnaires, or validate order forms before they're sent to you.

JavaScript documents can change appearance (sometimes upon request from the visitor), they can display graphics - on demand - and be used to implement web-based games.

Sadly, though, they can't make coffee to keep you going as you add more functionality and pizazz to your online, Web 2.0, interactive catalog that thinks it's a sales page.

JavaScript Course Links 

Suite101 Articles from LeckyT

Based on my upcoming book 'Just Enough Web Programming', these articles showcase the easiest techniques for client side JavaScript programming.

They change pretty often, though, so keep checking back!

(Squidoo offer a great facility for that - you can get this lens as a feed, or bookmark it.)

Loading Fetching RSS feed... please stand by

How do I get Started? 

You need to know about programming. You won't get very far without knowing a little bit. Now, if you really want to get to know programming, the following is going to help you:


Programming Concepts and Principles

However, the basics are actually pretty straightforward.

JavaScript programming allows you to (a) do something, (b) do something if a condition is satisfied, or (c) do something over and over until it's time to stop.

Doing Something
Put your code in functions. It's easier like that. Oh, a function is just a bit of named code. You use it to tell the computer to do something, using an easy to remember name. An example of a function is:

function MakeBackgroundRed () {
// code to make the background red
}

Of course, we haven't put in the code to actually do the work. Instead we've put in a comment that tells us what should go in the function, when we get around to doing it.

Doing something conditionally.
This is like saying - if the background is white, make it red. Of course, we have to know how to tell if the background is white, but let's just assume we can do that, and worry about how later on. So, the if statement:

if ( backgroundColor == white ) {
MakeBackgroundRed();
}

Oh look, we used our named code to make the background red! That funny double-equals sign just means 'equality', as in : is the bit on the left of it the same as the bit on the right?

Other possible signs include != (not equals), < (less than), > (more than), <=, and >=.

Do something over and over and over...
Ah, yes. Looping. This is more difficult. There are a few kinds of loop. There's the 'loop until I tell you to stop', the 'loop while something is true', and the 'loop for a few times'. Arguably, you don't need to know about all three, but in the spirit of completeness, we'll look at them after a brief commercial break.

JavaScript Programming Books from LeckyT 

Real paper books from the JavaScript Programming Lensmaster.

Just Enough Web Programming with XHTML, PHP, and MySQL

JEWP provides the reader with a crash course in everything from HTML, Dynamic HTML, XML, RSS, PHP and Server Side Scripting, JavaScript programming, SQL and then puts it all together in a set of web-based examples.

What more do you need to get your Web 2.0 applications up and running? Can you afford not to...?

Amazon Price: $22.79 (as of 05/16/2008)

JavaScript Programming : Loops 

Welcome back.

A loop is a piece of code that is designed to be performed over and over again. Firstly, the for loop:

for ( i = 0; i < 10; i++) {
// do something
}

No prizes for guessing what the above does. Yup, it does something (as yet not specified) ten times. 0 through 9. The i is called a variable, because what it contains can vary. In this case, we set it to 0, check that it is less than 10, and then add 1 to it (that's the i++ bit).

Easy, isn't it? The other kind of loop worth knowing about is the do ... while loop. If we wanted to do the same as above in a do ... while loop, it'd look like this:

i = 0;
do {
// do something
i++;
while (i < 10);

One last note. We put a semicolon after each statement to tell the computer that we've finished with our instruction.

Ok, as far as understanding simple JavaScript goes, that's about all that you'll need. Of course, if you want to write JavaScript code, you'll need to learn a whole lot more.

X

Hi, I'm LeckyT

LeckyT

Join my fan club

Author of Just Enough Web Programming, and countless articles on programming, my lenses reflect the need for every computer user to start learning programming.

Make the most of your machine, and your web site by adding JavaScript snippets following these simple instructions.

More pages by me...

See all my pages