PDA

View Full Version : Comparative Programming by example



jetboots
20 Oct 2005, 06:14 AM
So I'm learning javascript hardcore.

Im looking for a GOOD tutorial page that some of you may have run into that goes shows how to program a certain concepts and then follows through with EACH of the ideas. That is, it shows you start to finish 4 (for example) different ways of tackling the same problem using javascript. I am beginer/intermidiate and a fast learner if my few key questions about things are explained well (otherwise i will sit and ponder and try to find the answer to "seemingly" not too important stuff.

Yes, ive done the initial sweep through with Google, but I am looking for stuff INTPs found good (Google should work that into their search engine).

CoHo
20 Oct 2005, 01:22 PM
This isn't exactily what you describe, but it is a good site:
http://www.w3schools.com/js/js_examples.asp

PlayerOfGames
20 Oct 2005, 01:26 PM
Not really what you asked for, but I like learning by looking at good code, and the ninja skills at
http://www.walterzorn.com/dragdrop/dragdrop_e.htm impressed the hell out of me.

file cabinet
20 Oct 2005, 04:15 PM
there are very few good JavaScript resources on the web. I've gone through much of the good stuff that I generally don't need to look for anything anymore.
Best forum I've seen for JavaScript:
http://www.codingforums.com/forumdisplay.php?f=2
(also refer to its subforums)
there is also full documentation that can be downloaded.. but since devedge went down(netscape subdomain). If you desire this then PM me and I'd be able to email it to a given address.
Luckily the forum above has this thread:
http://www.codingforums.com/showthread.php?t=17254

this may be useful:
http://jibbering.com/faq/

and this:
http://www.jibbering.com/faq/faq_notes/faq_notes.html

if you have more specific questions either create a thread and I will see it or PM me. JavaScript has been receiving more attention lately because of the "AJAX" approach to web applications so that may be something to read about (and XUL/Firefox extensions are based around JS).

so.. different approaches to tackling the same problem?
doing OOP is fun in javascript but the OOP stuff isn't entirely well documented so not as many people seem to use it.
tutorials about JS(or any other language) usually only show you one solution instead of multiple.

here are some trivial examples of multiple ways to do the same thign:


var obj = new Object();
var obj = {};

var arr = new Array();
var arr = [];

var str = new String();
var str = '';

var number = new Number();
var number = 0;




function funcy() {
alert(1);
}

var funcy = function() {
alert(1);
}


/* why the above one is cool is because it means you
can pass a function as an argument, e.g.,
*/
var funcy = function() {
alert(1);
}

function mmtest(arg) {
arg();
/* or look in the arguments array which all functions have*/
arguments[0]();
}

mmtest(funcy);

/* usually you'll see something like this so that
they won't have to define a variable to pass it as an argument
*/
mmtest(function() {
alert('look at me');
});

/* anonymous functions [this will look familiar if
you've looked at greasemonkey scripts]
*/
var test = 10;
(function() {
var test = 20;
})();

alert(test);