SlideShare a Scribd company logo
JavaScript!
JavaScript v1
• Main features: handle browser events (load, mouse, etc.) and
  navigate and manipulate the web page document
• Primary original use was for image swapping on mouse events
  and basic form validation
• Browser rendering engines were too underpowered to do
  anything cool with it
• Inconsistent implementations between browsers
  • Netscape 3 (who made it) was a full version ahead of IE 3
JavaScript v1
• Most “serious” developers hated it
  •   No IDE
  •   No debugging tools
  •   Security flaws
  •   Marketed as “JavaScript for dummies”
  •   Mostly used by web designers
      copy-paste-ing code
Browser v4
• Netscape and IE 4 introduce completely separate
  implementations of Dynamic HTML / Document Object Model
• Libraries were created to make Netscape code work in IE and
  vice versa
• Lowest common denominator was too low to accomplish
  anything
Browser v4
• Two side effects:
  • Netscape died to give way to Mozilla, but it was years before
    Mozilla had a stable release, allowing IE to dominate market
    share
  • Flash was really the only consistent platform to do anything cool
My Favourite JavaScript Quote
“Anyway I know only one programming language worse than C
and that is JavaScript. [...] the net result is that the programming-
vacuum filled itself with the most horrible kluge in the history of
computing: JavaScript.”
 - Robert Cailliau
Enter AJAX
• Most devs more or less ignored JavaScript as a useful language
  until AJAX came along
• AJAX suddenly enabled great user experiences on web pages
  by loading data / html / scripts after the initial page load, not
  requiring a browser refresh between actions
• A number of cross-browser AJAX frameworks emerged that
  also enabled other cross-browser functionality
  • Prototype, jQuery, MooTools, Dojo, etc.
• Debugging tools created (firebug, dev console), better support
  in IDEs, browser rendering more powerful
• All in all, JavaScript is good now (or at least better)
JavaScript – Functions
• Functions are objects
  •   Have their own properties and methods (length, call, etc.)
  •   Can be assigned to variables
  •   Can be passed as arguments
  •   Can be returned by other functions
  •   Can be nested, maintaining scope (see: closure)
JavaScript – Objects
• Prototype-based Objects
  • Every object has a “prototype” property that references another
    object
  • Prototype is only used for retrieval
     • If our object doesn’t have the requested property, it’ll check its
       prototype (and its prototype, and its prototype, and so on…)
  • Prototypes are dynamic
     • editing a prototype means all of its objects are affected, regardless of
       when they were created
JavaScript – Literal Notation
•   Easy inline way to declare objects and arrays
•   aka JSON
•   Object: { Property: Value }
•   Array: [1, 2, 3]
•   Object Array: [{Property: Value}, {Property: Value}]
JavaScript – Scope
• Scope
  • Scope in JavaScript is controlled by Functions, not Blocks
  • Variables declared outside of a function / object (or without var)
    are automatically Global
      • Can lead to terrible conflicts between scripts
• Context (this)
  • “this” refers to the owner of the function being called
  • Anonymous functions are owned by Global (window)
  • Event handlers are owned by the control firing the event
    (sometimes)
JavaScript
• Bad Stuff
  •   Global Variables by default
  •   Lack of language-defined modules / namespaces
  •   No standard for distributing code across files
  •   Pretty small core library
  •   All numbers are binary floating points
       • Makes bitwise operators REALLY inefficient
  • NaN
       • typeof NaN === ‘number’ //true
       • NaN === NaN //false
  •   0, NaN, ‘’, false, null, and undefined all evaluate to false
  •   == behaves differently from ===
  •   No real way to “protect” source code / IP
  •   Still some browser-specific inconsistencies
       • *cough* Internet Explorer *cough*
jQuery
•   DOM selection using selector syntax
•   DOM traversal and modification
•   Event binding and delegation
•   CSS manipulation
•   AJAX
•   Extensibility
•   Cross-browser support
jQuery - Selectors
jQuery selectors are AWESOME.

Pre-jQuery                                              jQuery

var classElements = new Array();                        var classElements = $(“.happyCat”);
function getElementsByClassName(className, element) {
  if(element.className == className) {
     classElements.push(element);
  }
  for(var node in element.childNodes) {
     getElementsByClassName(
        className, node);
  }
}
getElementsByClassName(“sadPanda”,
  document.body);
jQuery - Selectors
                                                                    :last
   :animated
                   :visible       *alt=“backgroundImage”+
                                                                :even
    #playlistTable
                                      :checked
             :button                                        td.name + td.address

                              :contains(“Hello”)
   :parent                                             .className

                                              :gt(5)
    :first-child         table > tr




“#playlistTable td.name:odd > img*alt|=“chad”+:visible”
jQuery - Manipulation
• Allows reading, editing, insertion, deletion, and replication of
  elements and attributes in the document
   • $(‘#playlistTable’).append(“<div>Hello</div>”)
   • $(‘.userRow’).addClass(‘selected’);
   • $(‘#accountTable tr’).detach();
      • See also: $(‘#accountTable’).empty();
   • $(‘#errorMessage’).html(“<b>I didn’t say Simon Says</b>”);
   • $(‘#errorMessage’).css(‘color’, ‘red’);
   • $(‘#errorMessage’).css(‘color’); //returns ‘red’
   • $(‘input:text’).val(“I HAVE TAKEN OVER YOUR FORM”);
jQuery - Events
• Register functions to handle when the browser (or other code)
  triggers an event
  • $(‘input:button’).bind(‘click’, function() , alert(“CLICK.”); -);
  • $(‘div.hoverable’).delegate(‘mouseover’, handleHoverEvent);
  • $(document).ready(pageLoad);
jQuery - AJAX
• Make requests to the server for data / HTML / JavaScript
  without refreshing the page
  • get(“/products”, onProductsLoaded);
  • $(‘#widgetDialog’).load(“/widgets/editProduct”);
  • var formData = $(‘form’).serialize();
    post(“/saveProduct”, formdata, onProductSaved);
jQuery - Extensibility
• Hundreds of jQuery plugins
jQuery Templates
• Sends a template of how data should be represented with the
  page, then sends the data to fill that template with
Backbone.js
•   Client-side JavaScript MVC framework
•   Models with custom events
•   Collections with enumerable functions
•   Views with declarative event handling
•   Integrates with RESTful JSON web services
Backbone - Collections
• Represents a group of models
• Maps to a REST endpoint
  • /products
• Collection.fetch – calls REST endpoint, parses result, creates
  model objects, adds to collection
• Fires “refresh”, “add”, “remove”, “change” events
• Provides enumeration functions over models (foreach, find,
  map, max, min, sort, indexof, etc)
Backbone - Models
• Represents the data from the server as a property bag
  • Model.get(“property”), Model.set(,Property: “value”-)
• Provides methods to interact with REST service
  • Fetch, save, destroy
• Provides validation
• Fires events (“changed”)
Backbone - Views
• Represents the view of a model or a control on a page
  • More of a ViewModel than a true View
• Tied to a root element in the page (View.el)
• Responds to events on its model or collection
  • this.model.bind(‘change’, this.render);
• Declarative Events
   , “click .icon”: “open” -
• Use in conjunction with jQuery
  • this.$(‘.selector’) === $(‘.selector’, this.el)
Ad

More Related Content

What's hot (19)

Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Zeeshan Khan
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
baygross
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NET
James Johnson
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
Mark Rackley
 
D3.js and SVG
D3.js and SVGD3.js and SVG
D3.js and SVG
Karol Depka Pradzinski
 
Jquery
JqueryJquery
Jquery
Girish Srivastava
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQuery
Angel Ruiz
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
Mike Dirolf
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
jeresig
 
Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)
jeresig
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and Bling
Doug Neiner
 
jQuery
jQueryjQuery
jQuery
Dileep Mishra
 
jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009
Remy Sharp
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Siva Arunachalam
 
Organizing Code with JavascriptMVC
Organizing Code with JavascriptMVCOrganizing Code with JavascriptMVC
Organizing Code with JavascriptMVC
Thomas Reynolds
 
Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)
jeresig
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
tutorialsruby
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
dmethvin
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Zeeshan Khan
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
baygross
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NET
James Johnson
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
Mark Rackley
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQuery
Angel Ruiz
 
MongoDB at ZPUGDC
MongoDB at ZPUGDCMongoDB at ZPUGDC
MongoDB at ZPUGDC
Mike Dirolf
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
jeresig
 
Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)
jeresig
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and Bling
Doug Neiner
 
jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009
Remy Sharp
 
Organizing Code with JavascriptMVC
Organizing Code with JavascriptMVCOrganizing Code with JavascriptMVC
Organizing Code with JavascriptMVC
Thomas Reynolds
 
Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)
jeresig
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
dmethvin
 

Viewers also liked (6)

What The F#
What The F#What The F#
What The F#
RTigger
 
Total Engagement
Total EngagementTotal Engagement
Total Engagement
RTigger
 
Node.js
Node.jsNode.js
Node.js
RTigger
 
Give your web apps some backbone
Give your web apps some backboneGive your web apps some backbone
Give your web apps some backbone
RTigger
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive Extensions
RTigger
 
Single page apps and the web of tomorrow
Single page apps and the web of tomorrowSingle page apps and the web of tomorrow
Single page apps and the web of tomorrow
RTigger
 
What The F#
What The F#What The F#
What The F#
RTigger
 
Total Engagement
Total EngagementTotal Engagement
Total Engagement
RTigger
 
Give your web apps some backbone
Give your web apps some backboneGive your web apps some backbone
Give your web apps some backbone
RTigger
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive Extensions
RTigger
 
Single page apps and the web of tomorrow
Single page apps and the web of tomorrowSingle page apps and the web of tomorrow
Single page apps and the web of tomorrow
RTigger
 
Ad

Similar to JavaScript! (20)

Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
Salvatore Fazio
 
Jquery
JqueryJquery
Jquery
Zoya Shaikh
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Sean Burgess
 
Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
prince Loffar
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
tutorialsruby
 
Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)
Julie Meloni
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Marlon Jamera
 
jQuery Objects
jQuery ObjectsjQuery Objects
jQuery Objects
Steve Wells
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
Amir Barylko
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
Bui Kiet
 
Week3
Week3Week3
Week3
Will Gaybrick
 
Tips for writing Javascript for Drupal
Tips for writing Javascript for DrupalTips for writing Javascript for Drupal
Tips for writing Javascript for Drupal
Sergey Semashko
 
JS Essence
JS EssenceJS Essence
JS Essence
Uladzimir Piatryka
 
SPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentialsSPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentials
Mark Rackley
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
J query presentation
J query presentationJ query presentation
J query presentation
sawarkar17
 
J query presentation
J query presentationJ query presentation
J query presentation
akanksha17
 
Jqueryppt (1)
Jqueryppt (1)Jqueryppt (1)
Jqueryppt (1)
AndreaSmile06
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
Syed Moosa Kaleem
 
J query
J queryJ query
J query
Manav Prasad
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Sean Burgess
 
Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
prince Loffar
 
Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)Learning About JavaScript (…and its little buddy, JQuery!)
Learning About JavaScript (…and its little buddy, JQuery!)
Julie Meloni
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Marlon Jamera
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
Amir Barylko
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
Bui Kiet
 
Tips for writing Javascript for Drupal
Tips for writing Javascript for DrupalTips for writing Javascript for Drupal
Tips for writing Javascript for Drupal
Sergey Semashko
 
SPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentialsSPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentials
Mark Rackley
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
J query presentation
J query presentationJ query presentation
J query presentation
sawarkar17
 
J query presentation
J query presentationJ query presentation
J query presentation
akanksha17
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
Syed Moosa Kaleem
 
Ad

More from RTigger (14)

You Can't Buy Agile
You Can't Buy AgileYou Can't Buy Agile
You Can't Buy Agile
RTigger
 
Caching up is hard to do: Improving your Web Services' Performance
Caching up is hard to do: Improving your Web Services' PerformanceCaching up is hard to do: Improving your Web Services' Performance
Caching up is hard to do: Improving your Web Services' Performance
RTigger
 
Ready, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming languageReady, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming language
RTigger
 
Open source web services
Open source web servicesOpen source web services
Open source web services
RTigger
 
How to hire a hacker
How to hire a hackerHow to hire a hacker
How to hire a hacker
RTigger
 
Windows 8 programming with html and java script
Windows 8 programming with html and java scriptWindows 8 programming with html and java script
Windows 8 programming with html and java script
RTigger
 
Open regina
Open reginaOpen regina
Open regina
RTigger
 
Async in .NET
Async in .NETAsync in .NET
Async in .NET
RTigger
 
Hackers, hackathons, and you
Hackers, hackathons, and youHackers, hackathons, and you
Hackers, hackathons, and you
RTigger
 
AJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side TemplatesAJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side Templates
RTigger
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel Processing
RTigger
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQL
RTigger
 
Git’in Jiggy With Git
Git’in Jiggy With GitGit’in Jiggy With Git
Git’in Jiggy With Git
RTigger
 
Web Services
Web ServicesWeb Services
Web Services
RTigger
 
You Can't Buy Agile
You Can't Buy AgileYou Can't Buy Agile
You Can't Buy Agile
RTigger
 
Caching up is hard to do: Improving your Web Services' Performance
Caching up is hard to do: Improving your Web Services' PerformanceCaching up is hard to do: Improving your Web Services' Performance
Caching up is hard to do: Improving your Web Services' Performance
RTigger
 
Ready, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming languageReady, set, go! An introduction to the Go programming language
Ready, set, go! An introduction to the Go programming language
RTigger
 
Open source web services
Open source web servicesOpen source web services
Open source web services
RTigger
 
How to hire a hacker
How to hire a hackerHow to hire a hacker
How to hire a hacker
RTigger
 
Windows 8 programming with html and java script
Windows 8 programming with html and java scriptWindows 8 programming with html and java script
Windows 8 programming with html and java script
RTigger
 
Open regina
Open reginaOpen regina
Open regina
RTigger
 
Async in .NET
Async in .NETAsync in .NET
Async in .NET
RTigger
 
Hackers, hackathons, and you
Hackers, hackathons, and youHackers, hackathons, and you
Hackers, hackathons, and you
RTigger
 
AJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side TemplatesAJAX, JSON, and Client-Side Templates
AJAX, JSON, and Client-Side Templates
RTigger
 
Parallel Processing
Parallel ProcessingParallel Processing
Parallel Processing
RTigger
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQL
RTigger
 
Git’in Jiggy With Git
Git’in Jiggy With GitGit’in Jiggy With Git
Git’in Jiggy With Git
RTigger
 
Web Services
Web ServicesWeb Services
Web Services
RTigger
 

Recently uploaded (20)

Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 

JavaScript!

  • 2. JavaScript v1 • Main features: handle browser events (load, mouse, etc.) and navigate and manipulate the web page document • Primary original use was for image swapping on mouse events and basic form validation • Browser rendering engines were too underpowered to do anything cool with it • Inconsistent implementations between browsers • Netscape 3 (who made it) was a full version ahead of IE 3
  • 3. JavaScript v1 • Most “serious” developers hated it • No IDE • No debugging tools • Security flaws • Marketed as “JavaScript for dummies” • Mostly used by web designers copy-paste-ing code
  • 4. Browser v4 • Netscape and IE 4 introduce completely separate implementations of Dynamic HTML / Document Object Model • Libraries were created to make Netscape code work in IE and vice versa • Lowest common denominator was too low to accomplish anything
  • 5. Browser v4 • Two side effects: • Netscape died to give way to Mozilla, but it was years before Mozilla had a stable release, allowing IE to dominate market share • Flash was really the only consistent platform to do anything cool
  • 6. My Favourite JavaScript Quote “Anyway I know only one programming language worse than C and that is JavaScript. [...] the net result is that the programming- vacuum filled itself with the most horrible kluge in the history of computing: JavaScript.” - Robert Cailliau
  • 7. Enter AJAX • Most devs more or less ignored JavaScript as a useful language until AJAX came along • AJAX suddenly enabled great user experiences on web pages by loading data / html / scripts after the initial page load, not requiring a browser refresh between actions • A number of cross-browser AJAX frameworks emerged that also enabled other cross-browser functionality • Prototype, jQuery, MooTools, Dojo, etc. • Debugging tools created (firebug, dev console), better support in IDEs, browser rendering more powerful • All in all, JavaScript is good now (or at least better)
  • 8. JavaScript – Functions • Functions are objects • Have their own properties and methods (length, call, etc.) • Can be assigned to variables • Can be passed as arguments • Can be returned by other functions • Can be nested, maintaining scope (see: closure)
  • 9. JavaScript – Objects • Prototype-based Objects • Every object has a “prototype” property that references another object • Prototype is only used for retrieval • If our object doesn’t have the requested property, it’ll check its prototype (and its prototype, and its prototype, and so on…) • Prototypes are dynamic • editing a prototype means all of its objects are affected, regardless of when they were created
  • 10. JavaScript – Literal Notation • Easy inline way to declare objects and arrays • aka JSON • Object: { Property: Value } • Array: [1, 2, 3] • Object Array: [{Property: Value}, {Property: Value}]
  • 11. JavaScript – Scope • Scope • Scope in JavaScript is controlled by Functions, not Blocks • Variables declared outside of a function / object (or without var) are automatically Global • Can lead to terrible conflicts between scripts • Context (this) • “this” refers to the owner of the function being called • Anonymous functions are owned by Global (window) • Event handlers are owned by the control firing the event (sometimes)
  • 12. JavaScript • Bad Stuff • Global Variables by default • Lack of language-defined modules / namespaces • No standard for distributing code across files • Pretty small core library • All numbers are binary floating points • Makes bitwise operators REALLY inefficient • NaN • typeof NaN === ‘number’ //true • NaN === NaN //false • 0, NaN, ‘’, false, null, and undefined all evaluate to false • == behaves differently from === • No real way to “protect” source code / IP • Still some browser-specific inconsistencies • *cough* Internet Explorer *cough*
  • 13. jQuery • DOM selection using selector syntax • DOM traversal and modification • Event binding and delegation • CSS manipulation • AJAX • Extensibility • Cross-browser support
  • 14. jQuery - Selectors jQuery selectors are AWESOME. Pre-jQuery jQuery var classElements = new Array(); var classElements = $(“.happyCat”); function getElementsByClassName(className, element) { if(element.className == className) { classElements.push(element); } for(var node in element.childNodes) { getElementsByClassName( className, node); } } getElementsByClassName(“sadPanda”, document.body);
  • 15. jQuery - Selectors :last :animated :visible *alt=“backgroundImage”+ :even #playlistTable :checked :button td.name + td.address :contains(“Hello”) :parent .className :gt(5) :first-child table > tr “#playlistTable td.name:odd > img*alt|=“chad”+:visible”
  • 16. jQuery - Manipulation • Allows reading, editing, insertion, deletion, and replication of elements and attributes in the document • $(‘#playlistTable’).append(“<div>Hello</div>”) • $(‘.userRow’).addClass(‘selected’); • $(‘#accountTable tr’).detach(); • See also: $(‘#accountTable’).empty(); • $(‘#errorMessage’).html(“<b>I didn’t say Simon Says</b>”); • $(‘#errorMessage’).css(‘color’, ‘red’); • $(‘#errorMessage’).css(‘color’); //returns ‘red’ • $(‘input:text’).val(“I HAVE TAKEN OVER YOUR FORM”);
  • 17. jQuery - Events • Register functions to handle when the browser (or other code) triggers an event • $(‘input:button’).bind(‘click’, function() , alert(“CLICK.”); -); • $(‘div.hoverable’).delegate(‘mouseover’, handleHoverEvent); • $(document).ready(pageLoad);
  • 18. jQuery - AJAX • Make requests to the server for data / HTML / JavaScript without refreshing the page • get(“/products”, onProductsLoaded); • $(‘#widgetDialog’).load(“/widgets/editProduct”); • var formData = $(‘form’).serialize(); post(“/saveProduct”, formdata, onProductSaved);
  • 19. jQuery - Extensibility • Hundreds of jQuery plugins
  • 20. jQuery Templates • Sends a template of how data should be represented with the page, then sends the data to fill that template with
  • 21. Backbone.js • Client-side JavaScript MVC framework • Models with custom events • Collections with enumerable functions • Views with declarative event handling • Integrates with RESTful JSON web services
  • 22. Backbone - Collections • Represents a group of models • Maps to a REST endpoint • /products • Collection.fetch – calls REST endpoint, parses result, creates model objects, adds to collection • Fires “refresh”, “add”, “remove”, “change” events • Provides enumeration functions over models (foreach, find, map, max, min, sort, indexof, etc)
  • 23. Backbone - Models • Represents the data from the server as a property bag • Model.get(“property”), Model.set(,Property: “value”-) • Provides methods to interact with REST service • Fetch, save, destroy • Provides validation • Fires events (“changed”)
  • 24. Backbone - Views • Represents the view of a model or a control on a page • More of a ViewModel than a true View • Tied to a root element in the page (View.el) • Responds to events on its model or collection • this.model.bind(‘change’, this.render); • Declarative Events , “click .icon”: “open” - • Use in conjunction with jQuery • this.$(‘.selector’) === $(‘.selector’, this.el)
  翻译: