Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at CFUNITED 2010 (Landsdown, VA) with: Mike Collins

Win A Copy Of JavaScript Enlightenment By Cody Lindley

By Ben Nadel on

A few weeks ago, I blogged about Cody Lindley's new book, JavaScript Enlightenment. Like his previous book - jQuery Enlightenment - Lindley's new book makes use of technical thin-slicing - preferring simple code samples over prose when it comes to exploring the JavaScript language. This keeps the book brief and enjoyable while still acting as a highly effective learning medium.

Luckily, Cody has given me three copies of his book to give away for free! And, since JavaScript Enlightenment is all about mastering the JavaScript "Object", I thought I would try to keep the contest object-centric.

In order to enter, you must leave a comment below!

But, it's not quite that simple! On Friday at 3PM EST, I'm going to pick the winners from the "valid" comments. And, what is a "valid" comment, you ask? Well, for that, you'll have to look at the code below, which showcases just a few of the concepts that are explored, in-depth, in Cody Lindley's JavaScript Enlightenment.

  • <!DOCTYPE html>
  • <html>
  • <head>
  • <title>JavaScript Enlightenment By Cody Lindley</title>
  • </head>
  • <body>
  •  
  • <h1>
  • JavaScript Enlightenment By Cody Lindley
  • </h1>
  •  
  • <form>
  •  
  • <p>
  • Enter user's comment here:
  • </p>
  •  
  • <p>
  • <textarea name="comment" rows="10" cols="70"></textarea>
  • </p>
  •  
  • <p>
  • <button type="submit">Validate Comment</button>
  • </p>
  •  
  • </form>
  •  
  •  
  • <!-- Run scripts on DOM. -->
  • <script type="text/javascript" src="./jquery-1.6.1.js"></script>
  • <script type="text/javascript">
  •  
  •  
  • String.prototype.contains = function( substring ){
  • return( this.indexOf( substring) >= 0 );
  • };
  •  
  • function Comment( content ){
  • this.content = content.toLowerCase();
  • }
  •  
  • Comment.prototype.isValid = function(){
  • return( isFun.call( this.content ) );
  • };
  •  
  • Comment.prototype.toString = function(){
  • return( this.isValid() );
  • }
  •  
  • function isFun(){
  • return(
  • this.contains( "wicked" ) ||
  • this.contains( "hella" ) ||
  • this.contains( "crazy" ) ||
  • this.contains( "retarded" )
  • );
  • }
  •  
  • $( "form" ).submit(
  • function( event ){
  •  
  • var input = this.elements[ "comment" ];
  •  
  • alert( new Comment( input.value ) );
  •  
  • event.preventDefault();
  •  
  • }
  • );
  •  
  •  
  • </script>
  • </body>
  • </html>

Good luck! And remember, JavaScript is wicked awesome!

IMPORTANT UPDATE: It was properly brought to my attention that some of the code in this give-away would be too complicated for people who didn't already have a decent understanding of the JavaScript language. This makes total sense. As such, I've created this video in order to walk (as best I can) through the JavaScript features that this code is using:


 
 
 

 
 
 
 
 

I hope that helps!




Reader Comments

The code is simple enought to understand, but just these few lines have enlightened me about the power of javascripts methods like call and apply combined with the ability to prototype everything open a new world of expérimentation that's not achievable by "traditional" languages. I would like to know more about it =)

Reply to this Comment

Today might've turned out hella retarded if I hadn't seen this awesome post about Cody's crazy wicked book giveaway! Great idea Ben!

Reply to this Comment

What a wicked way, to win this hella crazy deal, anyone who doesn't enter must be retarded and too lazy to post a comment!

Reply to this Comment

It's hella awesome that you got a few copies of this book to give away. One must be crazy and/or retarded to not want to participate in this awesome giveaway!

Reply to this Comment

What a hella wicked idea, winning this would make me less retarded about JavaScript and instead make me a crazy lil JS Ninja

Reply to this Comment

What the hella am I doing in order to win a good JavaScript book?

I am putting this text in jsFiddle, clicking "Run" and hoping to see "true" in the alert - like I'm retarded - so I'll win this crazy comment comepition on a totally wicked site!

Reply to this Comment

I just encountered a retarded hobo. It was hella crazy! He tried to steal my tickets to wicked [sic, as case is important in isValid()].

<3 Ross

Reply to this Comment

What a crazy idea to prevent wicked form submission by retarded spam-bots for this hella cool contest. Just a brillant captcha-version.

Reply to this Comment

I'm not retarded, but I do need to learn some wicked Javascript so I can get hella good at it and land myself a crazy cool job. :)

Reply to this Comment

It would be crazy if this code didn't follow the convention of capitalizing the constructor method Comment.

What's crazy is that the Comment object is tightly coupled to a function outside of it's self. This means the Comment could not be used on another page unless the implementer knew to create the isFun() method.

Not to sound retarded but I would have made the isFun method a parameter to the Comment constructor. Because passing functions is hella cool.

Reply to this Comment

Im putting my name in the hat for this crazy contest. I want my Javascript skills to be hella wicked and a bit less retarded : )

Reply to this Comment

Thanks for the hella wicked giveaway. One would have to be crazy not to want a copy of this book. I need it for one of my retarded friends that can't grok JavaScript.

Reply to this Comment

It would be wicked cool to get a copy of this book. Codey is the man and this book has been on my wish list for so long it's retarded.

Reply to this Comment

Wicked fun, though I never use the word retarded to refer to people, because I have a cousin who is retarded, and I am sensitive to it. He's one of the coolest and sweetest of all of the people I know. And though I do, from time to time, like to attempt to drive men crazy, I do not cuss, so I won't use that other word...and if that means I don't win the contest. Oh well. :-/

Reply to this Comment

What about modifying the code to use a table in the isFun() function to ease the reading of the code and code re-use?

BTW, I came across jQuery thanks to TiddlyWiki (www.tiddlywiki.org), a very powerful portable wiki based on JavaScript and jQuery.

Reply to this Comment

The Coachella music festival is held adjacent to the building that houses G4, the network that produces "Attack of the Show" and the thoroughly Chris-Hardwicked show "Web Soup". It b hangin' 'cross Wilshire from LaBreTarDEducationPits, yo. (Dis democrazy sez AWE-full spellins ok.)

And here's an alert: All of that's true.

Reply to this Comment

This contest is wicked crazy. I need to win so I'll no longer program so hella retarded. Even now, I use all four words when I only need one for a fun comment!

Reply to this Comment

Calling me crazy - i prefer enlightened in a different shade - but Cody is getting his well deserved $15 directly anyway!
:)

Reply to this Comment

This contest is wicked sick, hella fun, and crazy awesome, but definitely not retarded.

Reply to this Comment

My love for that book is retardedly obvious. Some think I'm crazy. I hella want to win this contest! Wicked-awesome fun!

Reply to this Comment

Hey guys, for anyone who had trouble following the code, I added a video walk-through in an attempt to explain the features. Hope that helps for anyone who was a little lost :D

Reply to this Comment

@Ben,

I'm not lost, but a word that would've made my post better was. I should have said:

... Chris-Hardwicked (nerdisted) ...

Reply to this Comment

Some code are wicked and short but unmaintainable.
Some code are hella simple but lengthy.
Some code are as crazy as spaghetti.
Some code are retarded as procedural.

yo' I'm enlightened by Javascript Enlightenment.

Reply to this Comment

I knew there would be some wicked code in there. Hopefully I'm not completely retarded when it comes to javascript. It would be a hella thing to win this crazy book

Reply to this Comment

this book is wicked cool, just like you and it is hella crazy that you give 3 of them away to us. i would surely make good use of this book since i am still too retarded for good javascript.

Reply to this Comment

Are you from bean town? Being that this is a hell of a crazy wicked idea, it is like you are retarded. How do you like them apples?

Reply to this Comment

An enlightingly valid wicked comment to post for getting Cody Lindleys JavaScript Enlightenment book from bennadel via velvetflair

Reply to this Comment

alert('' || "An enlightingly valid comment to post for getting 'Cody Lindley's JavaScript Enlightenment' book from @bennadel and this is not XSS as its without script tag!");

Reply to this Comment

@Ben,

I am thinking from your comment that most of us have gotten it completely and totally wrong, and don't know what we are talking about at all, although, compared to you, we may be able to be classified as medically retarded (I am NOT making fun of retarded people, btw, that would be wicked, but I am merely stating what might be able to be proved as a medical fact).

It may be crazy to explain this, but:

The retarded classification is granted to people, I believe, with an IQ of below 70. So it is 69 or below. Is that ironic?

The IQ score is based on a quotient (the q part) of a person's chronological age, compared to his or her's 'intellectual age' (the i part). That is how they used to do it, although due to political correctness and people's sensitivities to different 'types' of intelligence, they may have officially changed it by now. They formulated tests, and those tests are designed to attempt to 'meassure' the brain activity of people with questions that supposedly do that. I guess an alternative method COULD involve hooking electrodes and other fancy medical equipment up to a person's head and physically meassure the activity going on in their brain, but my guess is this would not be cost effective.

I could be totally wrong with all of the above, but that is how I understand it. I can boast...I consider it a good thing that MY BQ is higher than my IQ. }:^D Though some would not consider that necessarily a good thing. But what can ya do? (and BQ does NOT stand for Body-Odor Quotient lmao)

Anyway, this may be a little OT, but @Webmanwalking, interestingly enough, your post reminded me of a case, I think it was in 1984 or 1987...Bowers Vs. Hardwick, and I think it was in West Virginia. It was a sodomy case. The hardwick part of your post reminded me of that. Sorry. Some memories of law school never get flushed out of your head.

ok, back to the part about our comments possibly wrong...I realize there could be some sort of or implementation, at which I would not have to use all of the words presented, including the 'cuss' word, but I thought I would try to cover all my bases just in case. Because, it would be totally and completely wicked cool and totally radical, dude, to win one of those wickedly cool javascript books. :D I could really, really, really, REALLY use a book on javascript @ my job, and I really love javascript and would love to have one to enhance my performance with this technology at work. :-). Ok. Now my comment has degraded down to begging. :-/ I guess I'll post a picture of my dog (puppy) begging next. Whatever works, I guess. :-)

Reply to this Comment

What a neat contest. I don't want to enter for the winning as there are others who would benefit more (I'll buy the book, I promise!), but such a novel approach.

My wife teaches in special education and has injected me with a modicum of sensitivity to the "lesser abled," but what is so fascinating is that most of what used to be clinical terms to describe these conditions eventually find a place in the vituperative vernacular. Idiot, imbecile, retarded, all of their original clinical uses rendered obsolete because their usage eventually recast their literal meaning as offensive.

And full circle back to JavaScript, it's amazing that an unexpected usage can change the meaning (and value)

@Ben - between you and the author of this book, what a mitzvah to share and export this understanding of JavaScript - these concepts are what's going to continue building use cases for node.js, which IMHO is the single-greatest thing since butterscotch pudding. And I love me some butterscotch pudding.

Reply to this Comment

I'm pleased you are offering this hellawickedlycrazynonretarded contest and I hope to win. I've been looking forward to checking this book out for a few weeks now.

Reply to this Comment

@Anna,

Chris Hardwick is not a sodomite, as far as I know. He's the nerdy and very funny comedian host of "Web Soup" on G4 and of the (currently, overall) #21 ranked podcast, The Nerdist. That's more popular than the Ricky Gervais podcast! Or TED Talks!

He sometimes says "You've just been nerdisted!", hence the Hardwicked reference.

But again, not a sodomy defendant, to the best of my knowledge.

Reply to this Comment

I meant to add that the reason that by comparison, we would be classified as retarded is because of the relative intelligence of @Ben raising the bar higher. The tests make comparison of current intelligence at that age level for the meassurements of chronological age and intellectual age, and it takes an average from that. If @Ben were smarter, more intelligent, then that would bring the average up, and would impact all of those falling below @Ben's level of intelligence. At his age, all of his peers, those who were of lower intelligence than what he possesses would have a lower I.Q. than they would were he not skewering the results, and those who were below his chronological age would not be able to rise as high on the 'intellectual age', because what the average person at that age would know would be raised, due to @Ben's relative intelligence.

I somehow forgot to explain all of this. :-)

@Brian - in another court case, when it was still considered 'pc' to call someone an imbecile, the court decided that 'Three generations of imbeciles are enough!!!'...allowing and ruling constitutional mandatory sterilization of people inflicted with 'imbecilism', ending a genetic streak that spanned over 3 generations, and taking those genes out of the gene pool. I never did hear of the time when it was not considered an insult to call someone an idiot, I have no knowledge of the origin of that word. I will buy a book if I don't win the contest, and I am sure my previous comments have taken me out of the running and have ruined my chance anyway. :-) It would just be highly useful to me. And I ain't rich, so I'll have to budget for it if I end up having to purchase it. :-)

Reply to this Comment

@Anna - hope you win just on the merit of substance. "Moron," too, if I remember correctly, was all wrapped up in eugenics. My wife told me about some scale they used to use which classified them as moron, idiot, or imbecile by IQ. I'm a linguistic utilitarian on principle (what would you expect from an English major that codes because he loves syntax sooo much?) so it vexes me that we have to abandon clinical terms because of negative, non-literal associations. If you care about people in spite of nerd passion, though, it is what it is. And as much as I scream "idiot" or "moron" while driving, I'd hate to think someone walking by who fits the clinical definition of those terms would feel lesser for my insensitivity. Hence the new push to move away from MR as the clinical term in the current state of psychology/education. In a matter of years, we won't be any more sensitive about the perjorative use of "retard" than we are now about idiot, fortunately, and they'll have some new clinical term for the general population to corrupt.

And JavaScript will still be awesome!

Reply to this Comment

@Brian,

Thanks! And agreed -- it does irritate me that certain words have to be taken out and not uttered due to people's overuse of them and also to people perverting the original sense of them (it is a perversion, using a word in a way it is not meant to be used).

I've become de-sensitized to it, to some degree, because of all of the ignorant fools (I'm sure that came from somewhere) who throw terms around to be offensive.

There is a certain word that can't even hardly be said, which at one time was a completely acceptible and legal term for a group of people. The technical definition of this term was 'an ignorant person'. It came from 'ignorant'...nothing else. And yet, ignorant people (how ironic!!!) took it and turned it into this word that people are afraid to even say anymore, or that can cause such a raucus. In some dictionaries, the older ones, the term is still defined. And it is defined as an 'ignorant person'. It has been taken out of some dictionaries, and in others, there is some bogus bs about the word, which isn't even historically correct.

I think being a woman is WAY different. Because there are SO, SO many derogatory terms for women, and it has just become more or less commonplace for those terms to be thrown around and for women to accept them as 'compliments' and/or 'jokes'. I would say those words, those terms, used to describe women, are on the same level as the word mentioned above, but everyone pretty much expects us to just accept them. And if we don't, the we are bad sports, or we are way too sensitive, or we need to lighten up, or we are taking things way too seriously. There really aren't equivalent terms for men in general.

Reply to this Comment

I've taken a shellacking for my unenlightened (but well intentioned) abuse of JS; so I could use some Cody Lindley illumination!

Reply to this Comment

I nearly missed this due to procrastination. I had the crazy idea yesterday that I would post later, and nearly forgot until by random chance I checked the site today with only 2 hours left to submit.

Thanks, Ben, for all your wicked blog posts, you are hella awesome!

Reply to this Comment

@Brian,

My father was a clinical psychologist. One of his day-to-day functions was to administer IQ tests. So I can tell you how it used to be: 0-40 was idiot. 40-60 was imbecile. 60-80 was moron. 80-90 was dull normal. And 90-100 was normal.

Sometimes you run into definitions that seem unnecessarily precise on the boundary numbers. I suspect that they're basing their definitions on standard deviations from the mean. But a more useful definition is somewhat vague, based more on implications for care: Idiots require continual care and supervision. Imbeciles can dress themselves, clean up after themselves, etc. Morons can even hold a job. Those are more useful boundaries. Also, most IQ tests don't generally measure in those ranges, so they're more estimates in any case.

Among folks who are NOT mental health professionals, idiot, imbecile and moron became more derogatory over time, a process known as pejoration, as did retarded. Retarded used to be a euphemism, replacing slow or slow-minded (which seemed to indicate that they would never catch up). Retarded just meant further back in the pack, as if to say, given enough time, they would catch up.

Hope this helps.

Reply to this Comment

@WebManWalking,

Whoa, then that would mean by my IQ that I am WAY above normal (although my BQ is still higher than my IQ :^)) That was useful information, though. Thanks!

I thought retarded came from the...I THINK Latin (or was it Italian) term in music "Ritard" (or it could be "ritardo"), which means "slow" as in "slow down". I always thought that retarded just meant the person was slow. (and then, of course, people used it to be offensive).

Reply to this Comment

Hey guys, thanks so much for participating! I hope everyone had a great week programming and rocking out with their JavaScript out.

.... and the winners are:

Adam - It sure would be hella sweet to get a copy of this book! Wicked contest btw.

JAlpino - Wicked! I never thought to override the toString() method on my objects before.

Rob Dix - The jQuery book was hella good. I'd rip through this one like a crazy fiend!

Shoot me an email at - ben[at]bennadel.com - and I'll give you the discount code for the free book.

Cheers!

Reply to this Comment

@Anna: Retarded just means late again. Tardy means late. The sounds of a marching band's drums reach the stands behind the music, resulting in a retarded beat. Behind, late.

Reply to this Comment

@Adam, @JAlpino, and @Rob Dix,

Congratulations!

@WebManWalking,

When I said that "Ritard" in music meant "slow", what I meant was as in "slow down", as in when you are playing the piano, and there is a direction in italics above the staff that says "Ritard", and any piano player who has studied and played any amount of time knows that word means to "slow your playing down".

French being latin-based, in french, tard means slow as well, as in "Parlez plus tard alors je peux te comprends, s'il vous plait." That means, "Speak slower, please, so that I may understand you".

Reply to this Comment

@WebManWalking, Thanks for your kind explanation. As a father of a son with Autism, I really appreciate that.

Reply to this Comment

@Guillaume,

true...my mistake. Pardon. I don't get to practice my french too much in this non-french speaking nation. I apologize. Do I know you? I knew a Guillaume once, who was french, but I don't think he spelled his name that way. But I could be wrong.

@Ben,

I hope you are surviving that hurricane Irene and the aftermath, and that everything is fine with you up there.

Reply to this Comment

Wicked cool contest, I love little challenges like this. Was hella sad to see you add the video, decreases my chances of winning!

Reply to this Comment

What do you call a helicopter with jet propulsion, does loop-da-loops, and has no seat belts?

A hellacopter!

Reply to this Comment

I know it is late to win but figured I'd comment anyway.

Wicked is an interesting word. In the Northeast where I live you can use the word wicked as in "wicked cool" and people know you mean very good. But if you you use wicked that way in other parts of the country they have no idea what you mean and look at you like you are hella retarded. Once you explain it to them they just think you're crazy.

:)

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.