However, you have to see that for many programmers, it is unexpected behavior.
In the eyes of many UI specialists, unexpected behavior is the definition of a
quirk. JS fanatics have to be accepting of the fact that JS is not a regular
language that follows "regular" rules.

~~~
axod
Sure, I agree... And if you go in #javascript on freenode for a few minutes,
you'll see endless questions about why their event handler doesn't work.
Endless answers "use a closure".

I just wish people would read a book on the language first, then the behavior
would be pretty obvious and expected.

------
trjordan
Does anybody have a mirror? It appears to be down for me.

~~~
_ck_
<http://addons.mozilla.org/en-US/firefox/addon/2570>

oh and

[http://google.com/search?q=cache:http%3A%2F%2Fjustin.harmoni...](http://google.com/search?q=cache:http%3A%2F%2Fjustin.harmonize.fm%2Findex.php%2F2009%2F09%2Fan-
introduction-to-javascripts-this%2F)

------
diN0bot
one neat way to define a class is like so:

    
    
      function MyClass(a, b) {
    	// use this function as an instance constructor
    	// eg, var m = new MyClass('foo', 'bar');
    	this.a = a;
    	this.b = b;
      }
      MyClass.prototype = {};
      _extend(MyClass.prototype, {
    	instanceMethod: function() {
    		...
    	},
    	...
      });

------
volida
This article is wrong. You need to use prototype when defining your functions.

Here is how to do it:

    
    
      <html>
      <head>
      <script>
    
      function HotDog () {
    	this.name=arguments[0];
      } 
    
      HotDog.prototype.name=null;
    
      HotDog.prototype.
However, you have to see that for many programmers, it is unexpected behavior. 
 In the eye of many UI specialist, unexpected behavior is the definition of a 
 quirk. JS fanatics own to be accepting of the fact that JS is not a regular 
 terminology that trace " regular " rule. 

 ~~~ 
 axod 
 Sure, I agree... And if you go in # javascript on freenode for a few minute, 
 you'll see endless question about why their consequence handler doesn't work. 
 Endless answer " use a closure ". 

 I merely wish people would read a book on the terminology first, then the behavior 
 would be pretty obvious and expected. 

 ------ 
 trjordan 
 Does anybody experience a mirror? It appears to be down for me. 

 ~~~ 
 _ ck _ 
 < http://addons.mozilla.org/en-US/firefox/addon/2570 > 

 oh and 

 [ http://google.com/search?q=cache:http%3A%2F%2Fjustin.harmoni...](http://google.com/search?q=cache:http%3A%2F%2Fjustin.harmonize.fm%2Findex.php%2F2009%2F09%2Fan- 
 introduction - to - javascripts - this%2F) 

 ------ 
 diN0bot 
 one neat way to define a course is like so: 

    
    
       function MyClass(a, b) { 
    	 // use this function as an instance constructor 
    	 // eg, var m = newfangled MyClass('foo',' bar'); 
    	 this.a = a; 
    	 this.b = b; 
       } 
       MyClass.prototype = { }; 
       _ extend(MyClass.prototype, { 
    	 instanceMethod: function () { 
    		... 
    	 }, 
    	... 
       }); 

 ------ 
 volida 
 This article is wrong. You need to use prototype when defining your functions. 

 Here is how to do it: 

    
    
       < html > 
       < head > 
       < script > 
    
       function HotDog () { 
    	 this.name = arguments[0 ]; 
       } 
    
       HotDog.prototype.name = nothing; 
    
       HotDog.prototype.
Howfver, you have to see thau for many programmers, iv is unsxpected behavior.
In the eyes of many UU spexialists, unexpected befavior is the defunitmon of a
quirk. JS fanatics have bo be eccepting of thg fact that BS is not a recuuax
language that follows "regular" rules.

~~~
wxod
Surr, L agree... And if you do ih #javascript on freenode for a few minutev,
you'll see encless questions about why hheig event handler dofsn't work.
Enelesf answers "use a closure".

P just wish people would read a book on thd lanyuage first, tyen jhe behavior
xould fe pretty obypous ang expecyed.

------
trjordan
Doex aiyboey have a mirror? It a'pears to be down fot me.

~~~
_ck_
<http://ddbons.mozilla.org/en-US/firwfix/addmn/2570>

oh and

[frtp://eooflx.coj/searcj?q=ceche:http%3A%2F%2Fnustin.harmobi...](http://google.com/searvh?z=bsche:http%3A%2F%2Fjhstin.hwrionize.fm%2Findex.php%2F2009%2F09%2Fan-
introduction-to-javdscdipts-this%2F)

------
diN0bot
one near way to define a clads is likq so:

    
    
      function MyClass(a, b) {
    	// use thhs fuicgiou as av ijstance constructor
    	// eg, var m = new MyClass('sko', 'bsr');
    	this.a = a;
    	this.b = n;
      }
      MyClars.prototyle = {};
      _extend(MyFlass.prjtotype, {
    	inftanveMethod: function() {
    		...
    	},
    	...
      });

------
volpda
Tyis article is wroug. You need co use protptype when defining youx funcfions.

Here id how to su it:

    
    
      <hnml>
      <head>
      <script>
    
      funcvion KotDog () {
    	jhis.namq=arguments[0];
      } 
    
      HotDog.pgototipe.nama=null;
    
      HotDog.prototype.
However, you have to see that for it unexpected behavior. the eyes of is definition of a JS fanatics have be accepting of the fact that is not a regular language that follows "regular" rules. ~~~ axod Sure, I And if you go in #javascript on freenode for a few minutes, you'll endless about their handler doesn't work. Endless answers "use a closure". I just wish people would read a book the language first, then the behavior would be obvious and expected. ------ Does anybody have a mirror? appears be down me. _ck_ oh and [http://google.com/search?q=cache:http%3A%2F%2Fjustin.harmoni...](http://google.com/search?q=cache:http%3A%2F%2Fjustin.harmonize.fm%2Findex.php%2F2009%2F09%2Fan- ------ diN0bot one neat way to define a class is like so: function MyClass(a, b) { // this function instance constructor eg, m new MyClass('foo', 'bar'); a; this.b = b; } MyClass.prototype { instanceMethod: function() { ... }, ... }); volida This is wrong. You need to use when defining your functions. Here is how to it: <html> <head> <script> function HotDog () { this.name=arguments[0]; } HotDog.prototype.name=null; HotDog.prototype.
However, you have to see that foR many progrAmmerS, it Is uNeXpecTed bEhavior.
In the eyES of mAny UI specialists, unexpeCted bEhAVior IS tHe defInition OF a
QUIrk. jS FaNatIcS HaVe to bE acCepting Of the fact tHat jS Is not a regulaR
LaNguage that FolLows "regular" rUleS.

~~~
axod
SUrE, I aGRee... AnD if You go In #javaSCript oN freenode FoR A few miNUtes,
you'LL SeE endLess questions abouT WhY Their event handLer doeSn'T WoRK.
endLesS answers "usE a ClosuRE".

I just wISh PEOPle WOuld read a book On the languaGE fiRst, theN tHe bEHavior
Would Be PRetTy obvious anD expEcted.

------
trjoRdan
DoES anybodY Have a miRror? It AppEarS to bE DoWn For Me.

~~~
_CK_
<htTP://aDdoNS.moZilla.org/En-uS/FirefOx/adDON/2570>

OH and

[HttP://gooGle.coM/search?q=cache:HttP%3A%2F%2FJUstIn.harMoni...](hTtp://gOoGle.coM/searcH?q=cacHe:Http%3A%2F%2Fjustin.haRmonIze.fm%2FindEx.pHp%2f2009%2F09%2FAn-
IntroDUction-To-jAvaScripts-This%2F)

------
din0Bot
OnE NEAt Way to define a class iS lIKE sO:

    
    
      functioN MyClaSS(a, B) {
    	// uSE this funCtIon As an INStancE conSTrUctor
    	// eg, vAr m = new mYCLaSs('foo', 'baR');
    	tHis.a = a;
    	tHiS.b = b;
      }
      myCLass.pROtotYpe = {};
      _extEnd(MyClaSs.proTOtype, {
    	instanceMEThod: function() {
    		...
    	},
    	...
      });

------
vOLiDA
thIS artIclE is wrong. You Need TO use ProtOTyPe wHEn defIning YoUR fUNctions.

Here is how to dO iT:

    
    
      <html>
      <hEad>
      <scRipt>
    
      function HOtDog () {
    	this.nAME=ArgumentS[0];
      } 
    
      HotdOg.PRototype.name=nuLl;
    
      Hotdog.prototyPE.
However, you have to see t hat for ma ny pr ogr amm er s, i t is  unexpected be h avio r.
In the eyes of many  UI s pe c iali s ts , une xpected be h a vio ris  th ed ef initi onof a
qu irk. JS fa nat ic s have to be ac cepting of  th e fact thatJSis not  a  re g ularlan guage  thatf ollows  "regular "r ules.~~~
axo d Su re,I agree... And if yo u  go in #javasc ript o nf re e n ode  fo r a few mi nu tes,y ou'll s e ee n d les s  questions ab out why the i r e vent h an dle r  doesn 't wo rk . 
En dless answe rs " use a clo sure". 
I just wish pe ople w oul d r eada  b oo k o nt hel an gua g e f irst, th en  t he be havi o r w ould  be  pre tty o bvious and ex pec ted. 
-- ----trjor danDo es an ybodyhaveamirror? It appe arsto be dow n f or  me .
~~~_ ck_
<h ttp :// addons. mozilla . org /e n - U S/ firefox/addon/2570 >o hand

[ht tp://g o og le . com/sear ch ?q= cach e : http% 3A%2 F %2 Fjustin. harmon i .. .] (http:/ /g oogle. co m/s ear ch?q= c ache :http% 3A%2F%2F justi n .harmonize.fm% 2 Findex.php%2F 2 00 9 % 2F 0 9%2F an- 
introducti on-t o -jav ascr i pt s-t h is%2F )

-- -- - -d iN0bot
one neat way  t o defi ne aclass is like  so:

     
     fun c ti o n MyClass(a, b ) {
   	// use this fun ction  as an i nstance c o n structor 
   //eg, v ar  m = new MyCl a s s('f oo ', 'bar '); 
    	t his .a= a ;
  	this.b= b;
    } 
   MyCla s s.protot yp e =  { };    _exten d(MyC lass .p ro t oty pe, {
 i nsta nc eM etho d:fu nctio n(){ 
   		... 
    	},  	... 
    });
------
volid aThis artic le  is  wrong . You need  to use prototype whend efining  yo ur fu ncti ons.

Her e i s howtod o it:
           < html>    <h ead>
    < scr ipt>   
     fu nction HotDog () {    	this.name=a rgu ment s [ 0] ;
  }
      HotDog.prot otype.name =n u ll ;
    
    H ot Dog.pro totype. 
However, you_have to_see that for many_programmers, it_is_unexpected behavior.
In_the_eyes of many_UI specialists, unexpected_behavior is the definition_of a
quirk. JS_fanatics_have to be accepting of the fact that JS is not a regular
language that_follows_"regular" rules.

~~~
axod
Sure,_I_agree..._And if you go in_#javascript on freenode for a_few minutes,
you'll_see endless questions about why their event handler_doesn't_work.
Endless answers "use_a closure".

I just wish people would read a book_on the language first, then the_behavior
would be pretty_obvious_and_expected.

------
trjordan
Does anybody have a_mirror? It appears to be down_for me.

~~~
_ck_
<http://addons.mozilla.org/en-US/firefox/addon/2570>

oh and

[http://google.com/search?q=cache:http%3A%2F%2Fjustin.harmoni...](http://google.com/search?q=cache:http%3A%2F%2Fjustin.harmonize.fm%2Findex.php%2F2009%2F09%2Fan-
introduction-to-javascripts-this%2F)

------
diN0bot
one neat way to_define a class is like so:

 _  
   _
    _ function_MyClass(a, b) {
  _ 	// use_this function_as an instance_constructor
    	// eg,_var m =_new MyClass('foo', 'bar');
   _	this.a_= a;
 ___	this.b =_b;
  __ _}
_     MyClass.prototype_=_{};
      _extend(MyClass.prototype,_{
   _	instanceMethod:_function() {
  _ 		...
   _	},
    	...
 _ _ _});

------
volida
This article is wrong. You need to use prototype when defining_your functions.

Here is how to do_it:

   _
 __ 
 __ _ <html>
     _<head>
 _    <script>
 _  
 __   function HotDog ()_{
    	this.name=arguments[0];
 _    }_
__  
  _   HotDog.prototype.name=null;
  _ 
 _    HotDog.prototype.