SlideShare a Scribd company logo
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

More Related Content

What's hot

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
 
What is recursion?
What is recursion? What is recursion?
What is recursion?
AnuragSrivastava272
 
Presenting Seq for Node.js
Presenting Seq for Node.jsPresenting Seq for Node.js
Presenting Seq for Node.js
Douglas 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 giants
Ian Barber
 
Python and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihunPython and rust 2018 pythonkorea jihun
Python and rust 2018 pythonkorea jihun
JIHUN 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 6
FrontDays
 
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 features
GephenSG
 
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
goatcode
 
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
zakiakhmad
 
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
Mahmoud 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
 
Usp
UspUsp
gemdiff
gemdiffgemdiff
gemdiff
teeparham
 

What's hot (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
 

Viewers also liked

Facebook Social Media
Facebook Social MediaFacebook Social Media
Facebook Social Media
ebusiness brix
 
Dutch PHP Conference 2013: Distilled
Dutch PHP Conference 2013: DistilledDutch PHP Conference 2013: Distilled
Dutch PHP Conference 2013: Distilled
Zumba Fitness - Technology Team
 
E business brix
E business brixE business brix
E business brix
ebusiness brix
 
New things in php
New things in phpNew 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
Luca Marchesotti
 
Teatro solange
Teatro solangeTeatro solange
Teatro solangeadaonorato
 
Регистрация товарного знака в России
Регистрация товарного знака в РоссииРегистрация товарного знака в России
Регистрация товарного знака в Россииtabella_ipburo
 
Improvevlogteamfame
ImprovevlogteamfameImprovevlogteamfame
Improvevlogteamfameteamfame
 

Viewers also liked (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
 

Similar to Javascript: The Important Bits

JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
Thierry Wasylczenko
 
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 1
jsalonen Salonen
 
Asynchronous java script
Asynchronous java scriptAsynchronous java script
Asynchronous java script
Ron Martin
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
Wojciech Sznapka
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
Chris Ramakers
 
Promises in JavaScript
Promises in JavaScriptPromises in JavaScript
Promises in JavaScript
Revath 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 Testing
Lars 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
 
EcmaScript 6
EcmaScript 6 EcmaScript 6
EcmaScript 6
Manoj Kumar
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
Manoj 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 Practices
Edorian
 
One page app with AngularJS
One page app with AngularJSOne page app with AngularJS
One page app with AngularJS
Adam Štipák
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
priestmanmable
 

Similar to 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
 

Recently uploaded

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 

Recently uploaded (20)

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 

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