SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
JAVASCRIPT: THE
            IMPORTANT BITS
REVIEWING JAVASCRIPT AND JQUERY FUNDAMENTALS AS WELL AS A BRIEF
                        INTRO TO NODEJS
                  Chris Saylor ( @cjsaylor ) from Zumba Fitness ®
THINK YOU KNOW JAVASCRIPT?
     typeof [] === "array"; false
     0.1 + 0.2 === 0.3; false
     a === null; false
     0 == '0'; true
     1 == '1'; true
     '' == '0'; false
     '' == 0; true
     'false' == false; false

          True or false?
THINK YOU KNOW JAVASCRIPT?
rtr
 eun
{
  a "el"
   : hlo
}



             What does this return?
THINK YOU KNOW JAVASCRIPT?
LET'S GET STARTED WITH THE BASICS.
VARIABLES
When declairing a variable without the "var", it puts the variable in
             global space which can be problematic.


  fnto hlo){
   ucin el(
    ts1='el'
     et   hlo;   / goa soe
                  / lbl cp
    vrts2='el2; / ti fnto soe
     a et   hlo'  / hs ucin cp
  }

  hlo)
   el(;

  cnoelgts1;/ 'el'
   osl.o(et) / hlo;
  cnoelgts2;/ udfnd
   osl.o(et) / neie
SCOPING
     There is no block scoping, only function scoping:
fr(a i=0 i<1;i+ {
 o  vr   ;  0 +)
  cnoelgi;
   osl.o()
}
cnoelgi;/ pit 1
 osl.o() / rns 0



     If you want to block the scope of the above loop:
(ucin( {
 fnto   )
  fr(a i=0 i<1;i+ {
   o vr    ;  0 +)
    cnoelgi;
     osl.o()
  }
});
 ()
vri
 a   ;
cnoelgi;/ udfnd
 osl.o() / neie
SCOPE IN CALLBACKS
In callbacks, you can share variables from the parent function:
vroj={
 a   b
  ojau:'el'
   bVle hlo,
  ts:fnto( {
   et    ucin)
    vrsl =ti;
     a   ef  hs
      stieu(ucin){
       eTmotfnto(
        cnoelgti.bVle;/ udfnd
         osl.o(hsojau) / neie
        cnoelgsl.bVle;/ 'el'
         osl.o(efojau) / hlo
      } 1)
       , 0;
  }
}
OBJECTS AND "CLASSES"
Objects are like JSON with some class aspects known as prototypes.
OBJECTS AND "CLASSES"
                 An example class:


Aia =(ucin){
 nml  fnto(

 fnto Aia(ae {
  ucin nmlnm)
   ti.ae=nm;
    hsnm  ae
 }

 Aia.rttp.oe=fnto( {
  nmlpooyemv    ucin)
   rtr aetti.ae+'mvd';
    eun lr(hsnm    oe.)
 };

 rtr Aia;
  eun nml

});
 ()
COMMON JAVASCRIPT PATTERNS
IMMEDIATE EXECUTION FUNCTION
(ucin){
 fnto(
  / Yu lgchr
   / or oi ee
});
 ()



 This immediately executes your logic as anonymous scope.
PRIVATE PATTERN
vrgton =fnto( {
 a  eCut    ucin)
  vrcut=0
   a on    ;
  rtr fnto( {
   eun ucin)
     rtr +cut
      eun +on;
  }
}
vrnx =gton(;
 a  et   eCut)
cnoelgnx() / 1
 osl.o(et); /
cnoelgnx() / 2
 osl.o(et); /



This pattern allows you to expose only what you want exposed.
INITIALIZATION
                   Variable initialization:
vrvle=vle| 'oeau'
 a au  au | smvle;



                Complex object initialization:
({
  vl:1
   a1  ,
  vl:nl,
   a2  ul
  ii:fnto( {
   nt  ucin)
    ti.a2=2
     hsvl   ;
    rtr ti;
     eun hs
  }
}.nt)
 )ii(;
LET'S GO OVER JQUERY OPTIMIZATION.
SELECTOR CACHING
                    Bad:
$'smcas)tx(rpaesm tx.)
 (.oels'.et'elc oe et';
$'smcas)cs'oo' 'e';
 (.oels'.s(clr, rd)
$'smcas)fcs)
 (.oels'.ou(;



                    Good:
$'smcas)
 (.oels'
  .et'elc sm tx.)
   tx(rpae oe et'
  .s(clr,'e'
   cs'oo' rd)
  .ou(;
   fcs)
SELECTOR CACHING
             Caching with callbacks.
vr$oetecas=$'smohrls';
 a  smohrls  (.oetecas)
$'smcas)o(cik,fnto(){
 (.oels'.n'lc' ucine
  $oetecastx(sm eet)
   smohrls.et'oe vn';
};
 )



                 Caching "this":
$'smcas)o(cik,fnto() {
 (.oels'.n'lc' ucine)
  $hs=$ti)
   ti  (hs;
  $hstx(smtig)
   ti.et'oehn';
  $hshd(;
   ti.ie)
};
 )
EVENT ATTACHING
     When attaching events, use the "on" function.
$''.n'lc' fnto() {
 (a)o(cik, ucine)
  cnoelg' ln wscikd';
   osl.o(A ik a lce.)
};
 )



       What about dynamically generated links?
$dcmn)o(cik,'' fnto() {
 (ouet.n'lc' a, ucine)
  cnoelg' ln wscikd';
   osl.o(A ik a lce.)
};
 )
PROPERLY STOPPING EVENTS
       Returning false is not always a good thing:
$''.n'lc' fnto(){
 (a)o(cik, ucine
  cnoelg'tpigpoaain';
   osl.o(Sopn rpgto.)
  rtr fle
   eun as;
  / Sm a:
   / ae s
  / epeeteal(;
   / .rvnDfut)
  / esoPoaain)
   / .tprpgto(;
};
 )
$''.n'lc' fnto() {
 (a)o(cik, ucine)
  cnoelg'nte cik';
   osl.o(Aohr lc.)
  / Nvrgt cle bcueo te
   / ee  es ald eas f h
  / rtr flei teaoeeet
   / eun as n h bv vn.
};
 )
BASIC JQUERY PLUGIN STRUCTURE
(ucin$ {
 fnto()
  $f.yo =fnto( {
   .nmLg  ucin)
     rtr ti.ahfnto( {
      eun hsec(ucin)
          cnoelg$ti);
           osl.o((hs)
     };
      )
  }
}jur);
 (Qey)



                   Usage:
$''.yo(;
 (p)mLg)
INTRODUCTION TO NODEJS
Nodejs is an event-driven language built on Google's V8 (in c).

It's package manager is known as npm and is now packaged with
                            nodejs.
NODEJS: HELLO WORLD
vrht =rqie'tp)
 a  tp  eur(ht';
ht.raeevrfnto (e,rs {
 tpcetSre(ucin rq e)
  rswieed20 {CnetTp' 'etpan};
   e.rtHa(0, 'otn-ye: tx/li')
  rsed'el Wrdn)
   e.n(Hlo ol';
}.itn13)
 )lse(37;
cnoelg'evrrnigo pr 13';
 osl.o(Sre unn n ot 37)


             Source:   http://nodejs.org/about/
NODEJS: DEPENDANCY MANAGEMENT
You can manage dependencies for your nodejs app in package.json:
  {
      "ae:"apeap,
       nm"  sml-p"
      "eso" ".."
       vrin: 001,
      "eednis:{
       dpnece"
        "xrs" ".."
         epes: 25x
      }
  }




      This allows us to install our project dependencies with npm:
  nmisal
   p ntl
NODEJS: EXPRESS SERVER
         Our hello world example in express:
vrepes=rqie'xrs';
 a  xrs  eur(epes)
ap=epescetSre(
 p   xrs.raeevr)
apgt'' fnto(e,rs {
 p.e(/, ucinrq e)
  rssn(HloWrd)
   e.ed'el ol';
};
 )
aplse(37;
 p.itn13)
cnoelg'itnn o pr 13';
 osl.o(Lseig n ot 37)
NODEJS: CONNECT MIDDLEWARE
Routing middleware is anything that implements the request,
           response, and next function pattern.
/ Rqetlge
 / eus  ogr
fnto lge(e,rs nx){
 ucin ogrrq e, et
  cnoelg"ahrqetd "+rqpt)
   osl.o(Pt euse:   e.ah;
  nx(;
   et)
}




                  Using this middleware:
apgt'' lge,fnto(e,rs {
 p.e(/, ogr ucinrq e)
  rssn(HloWrd)
   e.ed'el ol';
};
 )
QUESTIONS?
Javascript: The Important Bits

Contenu connexe

Tendances

Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1Emmanuel Garcia
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorerithion
 
Presenting Seq for Node.js
Presenting Seq for Node.jsPresenting Seq for Node.js
Presenting Seq for Node.jsDouglas Muth
 
Ugly code
Ugly codeUgly code
Ugly codeOdd-e
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giantsIan Barber
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunJIHUN KIM
 
Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Corley S.r.l.
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays
 
Easily mockingdependenciesinc++ 2
Easily mockingdependenciesinc++ 2Easily mockingdependenciesinc++ 2
Easily mockingdependenciesinc++ 2drewz lin
 
ECMAScript 6 new features
ECMAScript 6 new featuresECMAScript 6 new features
ECMAScript 6 new featuresGephenSG
 
DPC15 uncon talk: How cyborg puppies can sniff out code smell
DPC15 uncon talk: How cyborg puppies can sniff out code smellDPC15 uncon talk: How cyborg puppies can sniff out code smell
DPC15 uncon talk: How cyborg puppies can sniff out code smellgoatcode
 
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom GregoryExploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregoryzakiakhmad
 
The Ring programming language version 1.3 book - Part 17 of 88
The Ring programming language version 1.3 book - Part 17 of 88The Ring programming language version 1.3 book - Part 17 of 88
The Ring programming language version 1.3 book - Part 17 of 88Mahmoud Samir Fayed
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)hasan0812
 

Tendances (19)

Os Practical Assignment 1
Os Practical Assignment 1Os Practical Assignment 1
Os Practical Assignment 1
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
 
What is recursion?
What is recursion? What is recursion?
What is recursion?
 
Presenting Seq for Node.js
Presenting Seq for Node.jsPresenting Seq for Node.js
Presenting Seq for Node.js
 
Ugly code
Ugly codeUgly code
Ugly code
 
C99[2]
C99[2]C99[2]
C99[2]
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihun
 
Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)Build a custom (micro)framework with ZF2 Components (as building blocks)
Build a custom (micro)framework with ZF2 Components (as building blocks)
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
 
Easily mockingdependenciesinc++ 2
Easily mockingdependenciesinc++ 2Easily mockingdependenciesinc++ 2
Easily mockingdependenciesinc++ 2
 
ECMAScript 6 new features
ECMAScript 6 new featuresECMAScript 6 new features
ECMAScript 6 new features
 
DPC15 uncon talk: How cyborg puppies can sniff out code smell
DPC15 uncon talk: How cyborg puppies can sniff out code smellDPC15 uncon talk: How cyborg puppies can sniff out code smell
DPC15 uncon talk: How cyborg puppies can sniff out code smell
 
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom GregoryExploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
 
The Ring programming language version 1.3 book - Part 17 of 88
The Ring programming language version 1.3 book - Part 17 of 88The Ring programming language version 1.3 book - Part 17 of 88
The Ring programming language version 1.3 book - Part 17 of 88
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
 
Yg byev2e
Yg byev2eYg byev2e
Yg byev2e
 
Usp
UspUsp
Usp
 
gemdiff
gemdiffgemdiff
gemdiff
 

En vedette

From Corporate Research 2 start-ups: chronicles of an ongoing journey
From Corporate Research 2 start-ups: chronicles of an ongoing journeyFrom Corporate Research 2 start-ups: chronicles of an ongoing journey
From Corporate Research 2 start-ups: chronicles of an ongoing journeyLuca Marchesotti
 
Teatro solange
Teatro solangeTeatro solange
Teatro solangeadaonorato
 
Регистрация товарного знака в России
Регистрация товарного знака в РоссииРегистрация товарного знака в России
Регистрация товарного знака в Россииtabella_ipburo
 
Improvevlogteamfame
ImprovevlogteamfameImprovevlogteamfame
Improvevlogteamfameteamfame
 

En vedette (9)

Facebook Social Media
Facebook Social MediaFacebook Social Media
Facebook Social Media
 
Dutch PHP Conference 2013: Distilled
Dutch PHP Conference 2013: DistilledDutch PHP Conference 2013: Distilled
Dutch PHP Conference 2013: Distilled
 
E business brix
E business brixE business brix
E business brix
 
10576
1057610576
10576
 
New things in php
New things in phpNew things in php
New things in php
 
From Corporate Research 2 start-ups: chronicles of an ongoing journey
From Corporate Research 2 start-ups: chronicles of an ongoing journeyFrom Corporate Research 2 start-ups: chronicles of an ongoing journey
From Corporate Research 2 start-ups: chronicles of an ongoing journey
 
Teatro solange
Teatro solangeTeatro solange
Teatro solange
 
Регистрация товарного знака в России
Регистрация товарного знака в РоссииРегистрация товарного знака в России
Регистрация товарного знака в России
 
Improvevlogteamfame
ImprovevlogteamfameImprovevlogteamfame
Improvevlogteamfame
 

Similaire à Javascript: The Important Bits

Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bitsChris Saylor
 
Creating windows store java script apps
Creating windows store java script appsCreating windows store java script apps
Creating windows store java script appsEugene Zharkov
 
A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1jsalonen Salonen
 
Asynchronous java script
Asynchronous java scriptAsynchronous java script
Asynchronous java scriptRon Martin
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and mythsWojciech Sznapka
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developersChris Ramakers
 
Promises in JavaScript
Promises in JavaScriptPromises in JavaScript
Promises in JavaScriptRevath S Kumar
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingLars Thorup
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016Manoj Kumar
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perltypester
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaTony Fabeen
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scriptingTony Fabeen
 
ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?장현 한
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best PracticesEdorian
 
One page app with AngularJS
One page app with AngularJSOne page app with AngularJS
One page app with AngularJSAdam Štipák
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxpriestmanmable
 

Similaire à Javascript: The Important Bits (20)

JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Javascript: the important bits
Javascript: the important bitsJavascript: the important bits
Javascript: the important bits
 
Creating windows store java script apps
Creating windows store java script appsCreating windows store java script apps
Creating windows store java script apps
 
A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1A Backbone.js Tutorial for the Impatient - Part 1
A Backbone.js Tutorial for the Impatient - Part 1
 
Asynchronous java script
Asynchronous java scriptAsynchronous java script
Asynchronous java script
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
 
Promises in JavaScript
Promises in JavaScriptPromises in JavaScript
Promises in JavaScript
 
JavaScript pitfalls
JavaScript pitfallsJavaScript pitfalls
JavaScript pitfalls
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit Testing
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perl
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?ES6, 잘 쓰고 계시죠?
ES6, 잘 쓰고 계시죠?
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best Practices
 
One page app with AngularJS
One page app with AngularJSOne page app with AngularJS
One page app with AngularJS
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 

Dernier

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Javascript: The Important Bits

  • 1. JAVASCRIPT: THE IMPORTANT BITS REVIEWING JAVASCRIPT AND JQUERY FUNDAMENTALS AS WELL AS A BRIEF INTRO TO NODEJS Chris Saylor ( @cjsaylor ) from Zumba Fitness ®
  • 2. THINK YOU KNOW JAVASCRIPT? typeof [] === "array"; false 0.1 + 0.2 === 0.3; false a === null; false 0 == '0'; true 1 == '1'; true '' == '0'; false '' == 0; true 'false' == false; false True or false?
  • 3. THINK YOU KNOW JAVASCRIPT? rtr eun { a "el" : hlo } What does this return?
  • 4. THINK YOU KNOW JAVASCRIPT?
  • 5. LET'S GET STARTED WITH THE BASICS.
  • 6. VARIABLES When declairing a variable without the "var", it puts the variable in global space which can be problematic. fnto hlo){ ucin el( ts1='el' et hlo; / goa soe / lbl cp vrts2='el2; / ti fnto soe a et hlo' / hs ucin cp } hlo) el(; cnoelgts1;/ 'el' osl.o(et) / hlo; cnoelgts2;/ udfnd osl.o(et) / neie
  • 7. SCOPING There is no block scoping, only function scoping: fr(a i=0 i<1;i+ { o vr ; 0 +) cnoelgi; osl.o() } cnoelgi;/ pit 1 osl.o() / rns 0 If you want to block the scope of the above loop: (ucin( { fnto ) fr(a i=0 i<1;i+ { o vr ; 0 +) cnoelgi; osl.o() } }); () vri a ; cnoelgi;/ udfnd osl.o() / neie
  • 8. SCOPE IN CALLBACKS In callbacks, you can share variables from the parent function: vroj={ a b ojau:'el' bVle hlo, ts:fnto( { et ucin) vrsl =ti; a ef hs stieu(ucin){ eTmotfnto( cnoelgti.bVle;/ udfnd osl.o(hsojau) / neie cnoelgsl.bVle;/ 'el' osl.o(efojau) / hlo } 1) , 0; } }
  • 9. OBJECTS AND "CLASSES" Objects are like JSON with some class aspects known as prototypes.
  • 10. OBJECTS AND "CLASSES" An example class: Aia =(ucin){ nml fnto( fnto Aia(ae { ucin nmlnm) ti.ae=nm; hsnm ae } Aia.rttp.oe=fnto( { nmlpooyemv ucin) rtr aetti.ae+'mvd'; eun lr(hsnm oe.) }; rtr Aia; eun nml }); ()
  • 12. IMMEDIATE EXECUTION FUNCTION (ucin){ fnto( / Yu lgchr / or oi ee }); () This immediately executes your logic as anonymous scope.
  • 13. PRIVATE PATTERN vrgton =fnto( { a eCut ucin) vrcut=0 a on ; rtr fnto( { eun ucin) rtr +cut eun +on; } } vrnx =gton(; a et eCut) cnoelgnx() / 1 osl.o(et); / cnoelgnx() / 2 osl.o(et); / This pattern allows you to expose only what you want exposed.
  • 14. INITIALIZATION Variable initialization: vrvle=vle| 'oeau' a au au | smvle; Complex object initialization: ({ vl:1 a1 , vl:nl, a2 ul ii:fnto( { nt ucin) ti.a2=2 hsvl ; rtr ti; eun hs } }.nt) )ii(;
  • 15. LET'S GO OVER JQUERY OPTIMIZATION.
  • 16. SELECTOR CACHING Bad: $'smcas)tx(rpaesm tx.) (.oels'.et'elc oe et'; $'smcas)cs'oo' 'e'; (.oels'.s(clr, rd) $'smcas)fcs) (.oels'.ou(; Good: $'smcas) (.oels' .et'elc sm tx.) tx(rpae oe et' .s(clr,'e' cs'oo' rd) .ou(; fcs)
  • 17. SELECTOR CACHING Caching with callbacks. vr$oetecas=$'smohrls'; a smohrls (.oetecas) $'smcas)o(cik,fnto(){ (.oels'.n'lc' ucine $oetecastx(sm eet) smohrls.et'oe vn'; }; ) Caching "this": $'smcas)o(cik,fnto() { (.oels'.n'lc' ucine) $hs=$ti) ti (hs; $hstx(smtig) ti.et'oehn'; $hshd(; ti.ie) }; )
  • 18. EVENT ATTACHING When attaching events, use the "on" function. $''.n'lc' fnto() { (a)o(cik, ucine) cnoelg' ln wscikd'; osl.o(A ik a lce.) }; ) What about dynamically generated links? $dcmn)o(cik,'' fnto() { (ouet.n'lc' a, ucine) cnoelg' ln wscikd'; osl.o(A ik a lce.) }; )
  • 19. PROPERLY STOPPING EVENTS Returning false is not always a good thing: $''.n'lc' fnto(){ (a)o(cik, ucine cnoelg'tpigpoaain'; osl.o(Sopn rpgto.) rtr fle eun as; / Sm a: / ae s / epeeteal(; / .rvnDfut) / esoPoaain) / .tprpgto(; }; ) $''.n'lc' fnto() { (a)o(cik, ucine) cnoelg'nte cik'; osl.o(Aohr lc.) / Nvrgt cle bcueo te / ee es ald eas f h / rtr flei teaoeeet / eun as n h bv vn. }; )
  • 20. BASIC JQUERY PLUGIN STRUCTURE (ucin$ { fnto() $f.yo =fnto( { .nmLg ucin) rtr ti.ahfnto( { eun hsec(ucin) cnoelg$ti); osl.o((hs) }; ) } }jur); (Qey) Usage: $''.yo(; (p)mLg)
  • 22. Nodejs is an event-driven language built on Google's V8 (in c). It's package manager is known as npm and is now packaged with nodejs.
  • 23. NODEJS: HELLO WORLD vrht =rqie'tp) a tp eur(ht'; ht.raeevrfnto (e,rs { tpcetSre(ucin rq e) rswieed20 {CnetTp' 'etpan}; e.rtHa(0, 'otn-ye: tx/li') rsed'el Wrdn) e.n(Hlo ol'; }.itn13) )lse(37; cnoelg'evrrnigo pr 13'; osl.o(Sre unn n ot 37) Source: http://nodejs.org/about/
  • 24. NODEJS: DEPENDANCY MANAGEMENT You can manage dependencies for your nodejs app in package.json: { "ae:"apeap, nm" sml-p" "eso" ".." vrin: 001, "eednis:{ dpnece" "xrs" ".." epes: 25x } } This allows us to install our project dependencies with npm: nmisal p ntl
  • 25. NODEJS: EXPRESS SERVER Our hello world example in express: vrepes=rqie'xrs'; a xrs eur(epes) ap=epescetSre( p xrs.raeevr) apgt'' fnto(e,rs { p.e(/, ucinrq e) rssn(HloWrd) e.ed'el ol'; }; ) aplse(37; p.itn13) cnoelg'itnn o pr 13'; osl.o(Lseig n ot 37)
  • 26. NODEJS: CONNECT MIDDLEWARE Routing middleware is anything that implements the request, response, and next function pattern. / Rqetlge / eus ogr fnto lge(e,rs nx){ ucin ogrrq e, et cnoelg"ahrqetd "+rqpt) osl.o(Pt euse: e.ah; nx(; et) } Using this middleware: apgt'' lge,fnto(e,rs { p.e(/, ogr ucinrq e) rssn(HloWrd) e.ed'el ol'; }; )