File tree Expand file tree Collapse file tree 6 files changed +17
-28
lines changed
Expand file tree Collapse file tree 6 files changed +17
-28
lines changed Original file line number Diff line number Diff line change 1313/***
1414 function application
1515 ***/
16- // define a function
16+ // define a function
1717var sayHi = function ( who ) {
1818return "Hello" + ( who ? ", " + who : "" ) + "!" ;
1919} ;
4242 partial application
4343 ***/
4444
45- // for illustration purposes
46- // not valid JavaScript
45+ // for illustration purposes
46+ // not valid JavaScript
4747
48- // we have this function
48+ // we have this function
4949function add ( x , y ) {
5050return x + y ;
5151}
5454add ( 5 , 4 ) ;
5555
5656// step 1 -- substitute one argument
57- function add ( 5
58- ,
59- y
60- )
61- {
57+ function add ( 5 , y ) {
6258return 5 + y ;
6359}
6460
6561// step 2 -- substitute the other argument
66- function add ( 5
67- ,
68- 4
69- )
70- {
62+ function add ( 5 , 4 ) {
7163return 5 + 4 ;
7264}
7365
7466/***
7567 currying
7668 ***/
7769
78- // a curried add()
79- // accepts partial list of arguments
70+ // a curried add()
71+ // accepts partial list of arguments
8072function add ( x , y ) {
8173var oldx = x , oldy = y ;
8274if ( typeof oldy === "undefined" ) { // partial
124116
125117function funcWithArgsFrozen ( frozenargs ) {
126118return function ( ) {
127- // could do an optmisation here - if called with no arguments
119+ // could do an optimisation here - if called with no arguments
128120// return exactly this function.
129121var args = Array . prototype . slice . call ( arguments ) ;
130122var newArgs = frozenargs . concat ( args ) ;
136128} ;
137129}
138130
139- ;
140-
141131return funcWithArgsFrozen ( [ ] ) ;
142132}
143133
Original file line number Diff line number Diff line change 1919 * the code or already part of the JavaScript engine of one of the browsers you support.
2020 * 3. You clearly document and communicate the change with the team.
2121 */
22- if ( typeof Object . prototype . myMethod !== "function" ) {
23- Object . prototype . myMethod = function ( ) {
22+ if ( typeof Object . prototype . myMethod !== "function" ) {
23+ Object . prototype . myMethod = function ( ) {
2424// implementation...
2525} ;
2626}
Original file line number Diff line number Diff line change 3535
3636// preferred v2, timeout instead of interval - no unnecessary ticks
3737var scrollTimeout ; // global for any pending scrollTimeout
38- var outerPane = $details . find ( ".details-pane-outer" ) ,
38+ var outerPane = $details . find ( ".details-pane-outer" ) ;
3939
40- $
41- ( window ) . scroll ( function ( ) {
40+ $ ( window ) . scroll ( function ( ) {
4241if ( scrollTimeout ) {
4342// clear the timeout, if one is pending
4443clearTimeout ( scrollTimeout ) ;
Original file line number Diff line number Diff line change 7373// box.constructor.prototype.m = "mmm"
7474box . attachEvent = function ( ) {
7575} ;
76- box . dettachEvent = function ( ) {
76+ box . detachEvent = function ( ) {
7777} ;
7878} ;
7979
Original file line number Diff line number Diff line change 1414
1515// Public Static Members
1616
17- // counstructor
17+ // constructor
1818var Gadget = function ( ) {
1919} ;
2020
110110return counter ;
111111} ;
112112
113- // overwrite the contructor
113+ // overwrite the constructor
114114return NewGadget ;
115115
116116} ( ) ) ; // execute immediately
Original file line number Diff line number Diff line change 77< body >
88< script >
99/* Title: method() Method
10- Description: adding convenient funcationality to a language
10+ Description: adding convenient functionality to a language
1111 */
1212
1313if ( typeof Function . prototype . method !== "function" ) {
You can’t perform that action at this time.
0 commit comments