SlideShare a Scribd company logo
Why Javascript Doesn’t Suck
or javascript outside the DOM
..sometimes it can suck

• Cross Browser DOM incompatibilities (and surprisingly its not all IE’s fault)


• Ugly looking code (compared to some other languages *cough* ruby *cough*)


• Poorly written code


• Global Namespace


• Lives inside the browser (it doesn’t have to)
but..

• Most widely used functional programming language ever (eat your heart out
  LISP)


• lambda’s FTW


• Objects!!! (and JSON)


• Metaprogramming goodness (think ruby)


• Duck typed


• Light and easy (pretty much the opposite of Java)
you too can make it suck less

                                                      Module Pattern
var Positioning = function(){
    //private members
    var _x = 0;
    var _y = 0;

    return {
        //priviledged functions, have access to private members/functions
        setPosition: function(x,y){
            _x = x;
            _y = y;
        },
        getPosition: function(){
             return new Array(_x, _y);
        }

    }
}();

Positioning.setPosition(50, 100);
Positioning.getPosition(); // [50, 100]
metaprogramming
var barCamp = {
                                                           “send”
   sayHello: function(){
       alert quot;Helloquot;;
   }

}
barCamp.sayHello // alerted quot;Helloquot;
barCamp['sayHello'] // alerted quot;Helloquot;
barCamp.hasOwnProperty('sayHello') // true
//define_method in 3 lines of code
Function.prototype.define_method = function(name, func){
   this.prototype[name] = func;
   return this;
}

Positioning.define_method('deletePositions', function(){...})
prototype this

                                        prototype inheritance
function Bar(){
    this.member = initializer;
    return this;
}
Bar.prototype.sayHello = function(){ alert quot;Hello I am Barquot;; }
var barObject = new Bar();
barObject.prototype == Bar.prototype
barObject.constructor == Bar()
barObject.sayHello() // alerts quot;Hello I am Barquot;
function Foo(){
    this.member = initializer;
    return this;
}
Foo.prototype = new Bar();
Foo.prototype.sayHello = function(){ alert quot;Hello I am Fooquot;; }
var fooObject = new Foo();
fooObject.sayHello() //alerts quot;Hello I am Fooquot;
no more new

function object(parentObject){
    //create a dummy constructor function for our new object
    function F(){};
    // the dummy function's prototype member is now the parentObject
    F.prototype = parentObject;
    // return an object with the dummy function's prototype member
    return new F();
}

var bar = {
   sayHello: function(){...}
};

var foo = object(bar);
foo.sayHello() // alerts “Hello I am Bar”
hold your arguments to later please

Bar.prototype.setFavoriteDrinks = function(person) {
    var drinks = Array.prototype.slice.apply(arguments, [1]);
    alert(person + quot;'s favorite drinks are: quot; + drinks.join(', '));
}
var barCamp = new Bar()
// hint ill accept any of these as a thank you later tonight
barCamp.setFavoriteDrinks(quot;the dudequot;, quot;White Russionquot;, quot;Red Bull and Vodkaquot;,
quot;Irish Car Bombquot;, quot;Guinessquot;);
//alert quot;the dude's favorite drinks are White Russion, Red Bull and Vodka, Irish
Car Bomb, Guinessquot;
bye bye browser
//model

                                                     TrimPath junction
Contact = function() {}
with (modelFor('Contact')) {
     validatesPresenceOf('first_name');
     validatesPresenceOf('last_name');
}
//controller
ContactController = function() {}
scaffold(ContactController, 'Contact');
//view
<h1>Contacts</h1>

 <%= linkToLocal('Create A New Contact', 'contact', 'newInstance') %>

 <ul>
   <% for (var i = 0; i < contacts.length; i++) { %>
      <li><%= linkToLocal(contacts[i].last_name + ', ' + contacts[i].first_name,
          'contact', 'show', contacts[i].id) %></li>
   <% } %>
 </ul>
thanks to...

         Doug Crockford Advanced Javascript 1 + 2:
    http://video.yahoo.com/video/play?vid=cccd4aa02a3993ab06e56af731346f78.1027823
   http://video.yahoo.com/video/play?vid=cccd4aa02a3993ab06e56af731346f78.1027832


 Dustin Diaz Javascript site: www.dustindiaz.com
         Douglas Crockford quot;Javascript - The Goodquot;
                    http://video.yahoo.com/video/play?vid=630959


   http://yuiblog.com/blog/2007/06/12/module-pattern/
and of course




      http://www.amazon.com/JavaScript-Definitive-Guide-David-Flanagan/dp/1565923928
Eric Allam - last100meters.com

payperpost.com

More Related Content

What's hot

Web 4 | Core JavaScript
Web 4 | Core JavaScriptWeb 4 | Core JavaScript
Web 4 | Core JavaScript
Mohammad Imam Hossain
 
Composition in JavaScript
Composition in JavaScriptComposition in JavaScript
Composition in JavaScript
Josh Mock
 
Php string function
Php string function Php string function
Php string function
Ravi Bhadauria
 
De 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWKDe 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWK
Adolfo Sanz De Diego
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
brian d foy
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
Ahmed Swilam
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
Bradley Holt
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
Eyal Vardi
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax BasicsRichard Paul
 
Methods of debugging - Atomate.net
Methods of debugging - Atomate.netMethods of debugging - Atomate.net
Methods of debugging - Atomate.net
Vitalie Chiperi
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden
 
Javascript
JavascriptJavascript
Javascript
orestJump
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 Views
Eyal Vardi
 
Functional Programming in PHP
Functional Programming in PHPFunctional Programming in PHP
Functional Programming in PHP
pwmosquito
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 
Desenvolvendo APIs usando Rails - Guru SC 2012
Desenvolvendo APIs usando Rails - Guru SC 2012Desenvolvendo APIs usando Rails - Guru SC 2012
Desenvolvendo APIs usando Rails - Guru SC 2012
Rafael Felix da Silva
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
Lorna Mitchell
 
Xmpp prebind
Xmpp prebindXmpp prebind
Xmpp prebind
Syed Arshad
 
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
Mark Niebergall
 
ekb.py - Python VS ...
ekb.py - Python VS ...ekb.py - Python VS ...
ekb.py - Python VS ...
it-people
 

What's hot (20)

Web 4 | Core JavaScript
Web 4 | Core JavaScriptWeb 4 | Core JavaScript
Web 4 | Core JavaScript
 
Composition in JavaScript
Composition in JavaScriptComposition in JavaScript
Composition in JavaScript
 
Php string function
Php string function Php string function
Php string function
 
De 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWKDe 0 a 100 con Bash Shell Scripting y AWK
De 0 a 100 con Bash Shell Scripting y AWK
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
 
Methods of debugging - Atomate.net
Methods of debugging - Atomate.netMethods of debugging - Atomate.net
Methods of debugging - Atomate.net
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
Javascript
JavascriptJavascript
Javascript
 
Angular 2.0 Views
Angular 2.0 ViewsAngular 2.0 Views
Angular 2.0 Views
 
Functional Programming in PHP
Functional Programming in PHPFunctional Programming in PHP
Functional Programming in PHP
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
Desenvolvendo APIs usando Rails - Guru SC 2012
Desenvolvendo APIs usando Rails - Guru SC 2012Desenvolvendo APIs usando Rails - Guru SC 2012
Desenvolvendo APIs usando Rails - Guru SC 2012
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
Xmpp prebind
Xmpp prebindXmpp prebind
Xmpp prebind
 
Data Types In PHP
Data Types In PHPData Types In PHP
Data Types In PHP
 
ekb.py - Python VS ...
ekb.py - Python VS ...ekb.py - Python VS ...
ekb.py - Python VS ...
 

Viewers also liked

Participación Ciudadana
Participación CiudadanaParticipación Ciudadana
Participación Ciudadanarebeca911
 
Lenon
LenonLenon
LenonNihao
 
Galicia
GaliciaGalicia
Galicia
dreikback
 
Presentación
PresentaciónPresentación
Presentaciónrebeca911
 
Día del estudiante
Día del estudianteDía del estudiante
Día del estudiante
porqueleer
 
Sistema nervioso central
Sistema nervioso centralSistema nervioso central
Sistema nervioso central
Ecoternura
 
Essentials Trailer
Essentials  TrailerEssentials  Trailer
Essentials Trailerpcarr
 
Julian Beever Desenhosnacal
Julian Beever DesenhosnacalJulian Beever Desenhosnacal
Julian Beever Desenhosnacal
guest4237f5
 
Sahara
SaharaSahara
Tour de fotográfico por España
Tour de fotográfico por EspañaTour de fotográfico por España
Tour de fotográfico por España
quienentravuelve
 
O Eterno Ideal De Beleza
O Eterno Ideal De BelezaO Eterno Ideal De Beleza
O Eterno Ideal De Belezaguest1d1887
 
Monday Notes #5 9 23 07
Monday Notes #5 9 23 07Monday Notes #5 9 23 07
Monday Notes #5 9 23 07James Ramos
 
Social Changes Power Point To Upload
Social Changes  Power  Point To UploadSocial Changes  Power  Point To Upload
Social Changes Power Point To Uploadwswitala
 
18 Sept Hogar De Cristo
18 Sept Hogar De Cristo18 Sept Hogar De Cristo
18 Sept Hogar De Cristoajrrul
 
Washington High School Presentation
Washington High School PresentationWashington High School Presentation
Washington High School Presentationarshield
 
Manual Mensis
Manual MensisManual Mensis
Manual Mensismensis
 
Ghirada Bar Camp Mvno.It Alessandro Morelli Andrey Golub
Ghirada Bar Camp   Mvno.It   Alessandro Morelli   Andrey GolubGhirada Bar Camp   Mvno.It   Alessandro Morelli   Andrey Golub
Ghirada Bar Camp Mvno.It Alessandro Morelli Andrey Golubalexmore
 

Viewers also liked (20)

Participación Ciudadana
Participación CiudadanaParticipación Ciudadana
Participación Ciudadana
 
Lenon
LenonLenon
Lenon
 
Galicia
GaliciaGalicia
Galicia
 
Presentación
PresentaciónPresentación
Presentación
 
Día del estudiante
Día del estudianteDía del estudiante
Día del estudiante
 
Sistema nervioso central
Sistema nervioso centralSistema nervioso central
Sistema nervioso central
 
Essentials Trailer
Essentials  TrailerEssentials  Trailer
Essentials Trailer
 
Julian Beever Desenhosnacal
Julian Beever DesenhosnacalJulian Beever Desenhosnacal
Julian Beever Desenhosnacal
 
Sahara
SaharaSahara
Sahara
 
Apresentaçao Sistemas Tutoriais
Apresentaçao Sistemas TutoriaisApresentaçao Sistemas Tutoriais
Apresentaçao Sistemas Tutoriais
 
Presentation1
Presentation1Presentation1
Presentation1
 
Tour de fotográfico por España
Tour de fotográfico por EspañaTour de fotográfico por España
Tour de fotográfico por España
 
O Eterno Ideal De Beleza
O Eterno Ideal De BelezaO Eterno Ideal De Beleza
O Eterno Ideal De Beleza
 
Prez Fst
Prez FstPrez Fst
Prez Fst
 
Monday Notes #5 9 23 07
Monday Notes #5 9 23 07Monday Notes #5 9 23 07
Monday Notes #5 9 23 07
 
Social Changes Power Point To Upload
Social Changes  Power  Point To UploadSocial Changes  Power  Point To Upload
Social Changes Power Point To Upload
 
18 Sept Hogar De Cristo
18 Sept Hogar De Cristo18 Sept Hogar De Cristo
18 Sept Hogar De Cristo
 
Washington High School Presentation
Washington High School PresentationWashington High School Presentation
Washington High School Presentation
 
Manual Mensis
Manual MensisManual Mensis
Manual Mensis
 
Ghirada Bar Camp Mvno.It Alessandro Morelli Andrey Golub
Ghirada Bar Camp   Mvno.It   Alessandro Morelli   Andrey GolubGhirada Bar Camp   Mvno.It   Alessandro Morelli   Andrey Golub
Ghirada Bar Camp Mvno.It Alessandro Morelli Andrey Golub
 

Similar to Orlando BarCamp Why Javascript Doesn't Suck

The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
Michael Girouard
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest UpdatesIftekhar Eather
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPresswpnepal
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
LearningTech
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
Daniel Knell
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
Johannes Hoppe
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
Johannes Hoppe
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
Chalermpon Areepong
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Seri Moth
 
Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.
Alberto Naranjo
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
Lars Jankowfsky
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
Donald Sipe
 

Similar to Orlando BarCamp Why Javascript Doesn't Suck (20)

The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
Intro to jquery
Intro to jqueryIntro to jquery
Intro to jquery
 
PHP pod mikroskopom
PHP pod mikroskopomPHP pod mikroskopom
PHP pod mikroskopom
 
Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 

Recently uploaded

Filing Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed GuideFiling Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed Guide
YourLegal Accounting
 
Lookback Analysis
Lookback AnalysisLookback Analysis
Lookback Analysis
Safe PaaS
 
Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111
zoyaansari11365
 
India Orthopedic Devices Market: Unlocking Growth Secrets, Trends and Develop...
India Orthopedic Devices Market: Unlocking Growth Secrets, Trends and Develop...India Orthopedic Devices Market: Unlocking Growth Secrets, Trends and Develop...
India Orthopedic Devices Market: Unlocking Growth Secrets, Trends and Develop...
Kumar Satyam
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
taqyed
 
April 2024 Nostalgia Products Newsletter
April 2024 Nostalgia Products NewsletterApril 2024 Nostalgia Products Newsletter
April 2024 Nostalgia Products Newsletter
NathanBaughman3
 
Cracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptxCracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptx
Workforce Group
 
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
PaulBryant58
 
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
creerey
 
PriyoShop Celebration Pohela Falgun Mar 20, 2024
PriyoShop Celebration Pohela Falgun Mar 20, 2024PriyoShop Celebration Pohela Falgun Mar 20, 2024
PriyoShop Celebration Pohela Falgun Mar 20, 2024
PriyoShop.com LTD
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
tanyjahb
 
The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...
awaisafdar
 
What are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdfWhat are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdf
HumanResourceDimensi1
 
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptxTaurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
my Pandit
 
Enterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdfEnterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdf
KaiNexus
 
Memorandum Of Association Constitution of Company.ppt
Memorandum Of Association Constitution of Company.pptMemorandum Of Association Constitution of Company.ppt
Memorandum Of Association Constitution of Company.ppt
seri bangash
 
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n PrintAffordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Navpack & Print
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
Erika906060
 
Set off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptxSet off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptx
HARSHITHV26
 
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
BBPMedia1
 

Recently uploaded (20)

Filing Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed GuideFiling Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed Guide
 
Lookback Analysis
Lookback AnalysisLookback Analysis
Lookback Analysis
 
Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111Introduction to Amazon company 111111111111
Introduction to Amazon company 111111111111
 
India Orthopedic Devices Market: Unlocking Growth Secrets, Trends and Develop...
India Orthopedic Devices Market: Unlocking Growth Secrets, Trends and Develop...India Orthopedic Devices Market: Unlocking Growth Secrets, Trends and Develop...
India Orthopedic Devices Market: Unlocking Growth Secrets, Trends and Develop...
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
April 2024 Nostalgia Products Newsletter
April 2024 Nostalgia Products NewsletterApril 2024 Nostalgia Products Newsletter
April 2024 Nostalgia Products Newsletter
 
Cracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptxCracking the Workplace Discipline Code Main.pptx
Cracking the Workplace Discipline Code Main.pptx
 
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
Accpac to QuickBooks Conversion Navigating the Transition with Online Account...
 
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
 
PriyoShop Celebration Pohela Falgun Mar 20, 2024
PriyoShop Celebration Pohela Falgun Mar 20, 2024PriyoShop Celebration Pohela Falgun Mar 20, 2024
PriyoShop Celebration Pohela Falgun Mar 20, 2024
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
 
The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...
 
What are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdfWhat are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdf
 
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptxTaurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
Taurus Zodiac Sign_ Personality Traits and Sign Dates.pptx
 
Enterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdfEnterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdf
 
Memorandum Of Association Constitution of Company.ppt
Memorandum Of Association Constitution of Company.pptMemorandum Of Association Constitution of Company.ppt
Memorandum Of Association Constitution of Company.ppt
 
Affordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n PrintAffordable Stationery Printing Services in Jaipur | Navpack n Print
Affordable Stationery Printing Services in Jaipur | Navpack n Print
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
 
Set off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptxSet off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptx
 
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
 

Orlando BarCamp Why Javascript Doesn't Suck

  • 1. Why Javascript Doesn’t Suck or javascript outside the DOM
  • 2. ..sometimes it can suck • Cross Browser DOM incompatibilities (and surprisingly its not all IE’s fault) • Ugly looking code (compared to some other languages *cough* ruby *cough*) • Poorly written code • Global Namespace • Lives inside the browser (it doesn’t have to)
  • 3. but.. • Most widely used functional programming language ever (eat your heart out LISP) • lambda’s FTW • Objects!!! (and JSON) • Metaprogramming goodness (think ruby) • Duck typed • Light and easy (pretty much the opposite of Java)
  • 4. you too can make it suck less Module Pattern var Positioning = function(){ //private members var _x = 0; var _y = 0; return { //priviledged functions, have access to private members/functions setPosition: function(x,y){ _x = x; _y = y; }, getPosition: function(){ return new Array(_x, _y); } } }(); Positioning.setPosition(50, 100); Positioning.getPosition(); // [50, 100]
  • 5. metaprogramming var barCamp = { “send” sayHello: function(){ alert quot;Helloquot;; } } barCamp.sayHello // alerted quot;Helloquot; barCamp['sayHello'] // alerted quot;Helloquot; barCamp.hasOwnProperty('sayHello') // true //define_method in 3 lines of code Function.prototype.define_method = function(name, func){ this.prototype[name] = func; return this; } Positioning.define_method('deletePositions', function(){...})
  • 6. prototype this prototype inheritance function Bar(){ this.member = initializer; return this; } Bar.prototype.sayHello = function(){ alert quot;Hello I am Barquot;; } var barObject = new Bar(); barObject.prototype == Bar.prototype barObject.constructor == Bar() barObject.sayHello() // alerts quot;Hello I am Barquot; function Foo(){ this.member = initializer; return this; } Foo.prototype = new Bar(); Foo.prototype.sayHello = function(){ alert quot;Hello I am Fooquot;; } var fooObject = new Foo(); fooObject.sayHello() //alerts quot;Hello I am Fooquot;
  • 7. no more new function object(parentObject){ //create a dummy constructor function for our new object function F(){}; // the dummy function's prototype member is now the parentObject F.prototype = parentObject; // return an object with the dummy function's prototype member return new F(); } var bar = { sayHello: function(){...} }; var foo = object(bar); foo.sayHello() // alerts “Hello I am Bar”
  • 8. hold your arguments to later please Bar.prototype.setFavoriteDrinks = function(person) { var drinks = Array.prototype.slice.apply(arguments, [1]); alert(person + quot;'s favorite drinks are: quot; + drinks.join(', ')); } var barCamp = new Bar() // hint ill accept any of these as a thank you later tonight barCamp.setFavoriteDrinks(quot;the dudequot;, quot;White Russionquot;, quot;Red Bull and Vodkaquot;, quot;Irish Car Bombquot;, quot;Guinessquot;); //alert quot;the dude's favorite drinks are White Russion, Red Bull and Vodka, Irish Car Bomb, Guinessquot;
  • 9. bye bye browser //model TrimPath junction Contact = function() {} with (modelFor('Contact')) { validatesPresenceOf('first_name'); validatesPresenceOf('last_name'); } //controller ContactController = function() {} scaffold(ContactController, 'Contact'); //view <h1>Contacts</h1> <%= linkToLocal('Create A New Contact', 'contact', 'newInstance') %> <ul> <% for (var i = 0; i < contacts.length; i++) { %> <li><%= linkToLocal(contacts[i].last_name + ', ' + contacts[i].first_name, 'contact', 'show', contacts[i].id) %></li> <% } %> </ul>
  • 10. thanks to... Doug Crockford Advanced Javascript 1 + 2: http://video.yahoo.com/video/play?vid=cccd4aa02a3993ab06e56af731346f78.1027823 http://video.yahoo.com/video/play?vid=cccd4aa02a3993ab06e56af731346f78.1027832 Dustin Diaz Javascript site: www.dustindiaz.com Douglas Crockford quot;Javascript - The Goodquot; http://video.yahoo.com/video/play?vid=630959 http://yuiblog.com/blog/2007/06/12/module-pattern/
  • 11. and of course http://www.amazon.com/JavaScript-Definitive-Guide-David-Flanagan/dp/1565923928
  • 12. Eric Allam - last100meters.com payperpost.com