SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Último

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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 

Último (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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

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'; }; )