SlideShare a Scribd company logo
Front-end dev
by Paul Comanici (darkyndy)
JavaScript is fun
[] + [] = ?
JavaScript is fun
[] + [] = ""

{} + {} = ?
JavaScript is fun
[] + [] = ""

{} + {} = NaN

1 + "-1" = ?
JavaScript is fun
[] + [] = ""

{} + {} = NaN

1 + "-1" = "1-1"

NaN + [] = ?
JavaScript is fun
[] + [] = ""

{} + {} = NaN

1 + "-1" = "1-1"

NaN + [] = "NaN"

1 + NaN = ?
JavaScript is fun
[] + [] = ""

{} + {} = NaN

1 + "-1" = "1-1"

NaN + [] = "NaN"

1 + NaN = NaN
JavaScript patterns
function () {
   var x = 0;
   if (x === 1) {
        var y = 1;
        //execute other logic...
   } else if (x === 2) {
        var z = 2;
        //custom logic
   }
}
JavaScript patterns
function () {                    Single var pattern
   var x = 0;                    Benefits:
                                 1. Provides a single place to look for all the local
   if (x === 1) {                variables needed by the function
                                 2. Prevents logical errors when a variable is used
        var y = 1;               before it's defined
        //execute other logic... 3. Helps you remember to declare variables and
                                 therefore minimize globals
                                 4. Is less code (to type and to transfer over the wire)
   } else if (x === 2) {
        var z = 2;
        //custom logic
   }
}
JavaScript patterns
var Animal = (function () {
      "use strict";
      var type = "cat",
           defaultType = "cat";
      return {
           getType: function () {
                return type;
           },
           setType: function (customType) {
                customType = customType || defaultType;
                type = customType;
           }
      };
}());
JavaScript patterns
var Animal = (function () {
      "use strict";
      var type = "cat",
           defaultType = "cat";            Module pattern
      return {
           getType: function () {
                return type;
           },
           setType: function (customType) {
                customType = customType || defaultType;
                type = customType;
           }
      };
}());
JavaScript patterns
var Animal = (function () {
        "use strict";
        var type = "cat",
               defaultType = "cat",
               getType = null,
               setType = null;
        getType = function () {
               return type;
        };
        setType = function (customType) {
               customType = customType || defaultType;
               type = customType;
        };
        return {
               getType: getType,
               setType: setType
        };
}());
JavaScript patterns
var Animal = (function () {
        "use strict";
        var type = "cat",
               defaultType = "cat",                 Revealing module pattern
               getType = null,
               setType = null;
        getType = function () {
               return type;
        };
        setType = function (customType) {
               customType = customType || defaultType;
               type = customType;
        };
        return {
               getType: getType,
               setType: setType
        };
}());
JavaScript patterns
JavaScript namespacing and closures combined with module pattern


base.js -> namespace creator
car.js -> module
JavaScript patterns (base.js)
(function () {                                                                        jQuery.each(nsp, function (j, n) {
                                                                                             pp = make(n, pp);
       "use strict";                                                                  });
       /*global window, jQuery, NK */                                                 pp.__name__ = ns;
       if (typeof NK !== "undefined") {                                               ret.push(pp);
                                                                                      switch (ret.length) {
                 return;                                                              case 0:
       }                                                                                     return null;
       window.NK = {                                                                  case 1:
                                                                                             return ret[0];
                 namespace : function (ns) {
                                                                                      default:
                           var ret = [],                                                     return ret;
                                   make = function (n, parent) {                      }
                                                                                  }
                                           parent = parent ||
                                                                             };
window;
                                                                     }());
                                           if (!parent.
hasOwnProperty(n)) {
                                                   parent[n] = {};
                                           }
                                           return parent[n];
                                   },
                                   nsp = ns.split("."),
                                   pp = null;
JavaScript patterns (car.js)
(function () {                                                                     getPropr: function (p) {
         "use strict";                                                                   if (p in my) {
                                                                                                  return my[p];
         /*global jQuery, NK */
                                                                                         }
         var my = {
                                                                                         return null;
                         type: "",                                                 },
                         color: "",                                                setPropr: function (p, v) {
                         origin: "",                                                     if (p in my) {
                         init: function () {                                                      my[p] = v;
                                     my.type = "audi";
                                                                                         }
                                                                                   }
                         },
                                                                               },
                         setColor: function (c) {                              obj = NK.namespace("NK.Car");
                                     c = c || "black";                 jQuery.extend(obj, {
                                     my.color = c;                   init: my.init,
                         },                                                    getPropr: my.getPropr,
                         getColor: function () {
                                                                               setPropr: my.setPropr,
                                                                               getColor: my.getColor,
                                     return my.color;
                                                                               setColor: my.setColor,
                         },                                                    setFerrari: my.setFerrari
                         setFerrari: function () {             });
                                     my.type = "ferrari";   }());
                                     my.color = "red";
                         },
JSLint
 1. function test() {
 2.      a = new Array();
 3.      a["d"] = "08";
 4.      aa = [1,2,3];
 5.      c = parseInt(a["d"]);
 6.      if (c == 8) {
 7.            for (var i=0;i<aa.length; i++){
 8.                  if (aa[i] == 2) console.log("true")
 9.                  console.log("false")
10.            }
11.      }
12. }
Google Developer Tools
- console
- debugger
- JS breakpoints
- DOM breakpoints
- live JS edit
- modify JS in debug
- access to private methods in debug
Google Developer Tools
Suggestions for sites to debug?
The end
Thanks,
          Paul Comanici (darkyndy)

More Related Content

KEY
Object Oriented Programming in js
KEY
(map Clojure everyday-tasks)
PDF
Jscex: Write Sexy JavaScript
PDF
Hw09 Hadoop + Clojure
PDF
深入浅出Jscex
PDF
Hadoop + Clojure
PDF
Jscex: Write Sexy JavaScript (中文)
Object Oriented Programming in js
(map Clojure everyday-tasks)
Jscex: Write Sexy JavaScript
Hw09 Hadoop + Clojure
深入浅出Jscex
Hadoop + Clojure
Jscex: Write Sexy JavaScript (中文)

What's hot (20)

PDF
响应式编程及框架
KEY
Coffee Scriptでenchant.js
PDF
The Ring programming language version 1.7 book - Part 83 of 196
PDF
Coffee script
PPTX
Ian 20150116 java script oop
PDF
Clojure: The Art of Abstraction
PDF
Linguistic Symbiosis between Actors and Threads
PPT
Using QString effectively
PDF
Start Wrap Episode 11: A New Rope
PDF
Python-GTK
PDF
Python and GObject Introspection
PDF
EMFPath
PDF
Kotlin Advanced - Apalon Kotlin Sprint Part 3
PDF
Something about Golang
KEY
連邦の白いヤツ 「Objective-C」
KEY
GoLightly: A Go Library For Building Virtual Machines
PDF
Better Software: introduction to good code
PDF
Doc Parsers Api Cheatsheet 1 0
PDF
Virtual machine and javascript engine
PDF
Javascript foundations: Function modules
响应式编程及框架
Coffee Scriptでenchant.js
The Ring programming language version 1.7 book - Part 83 of 196
Coffee script
Ian 20150116 java script oop
Clojure: The Art of Abstraction
Linguistic Symbiosis between Actors and Threads
Using QString effectively
Start Wrap Episode 11: A New Rope
Python-GTK
Python and GObject Introspection
EMFPath
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Something about Golang
連邦の白いヤツ 「Objective-C」
GoLightly: A Go Library For Building Virtual Machines
Better Software: introduction to good code
Doc Parsers Api Cheatsheet 1 0
Virtual machine and javascript engine
Javascript foundations: Function modules
Ad

Similar to front-end dev (20)

PPTX
Design patterns in javascript
PDF
Scala in practice
PDF
TypeScript Introduction
KEY
Engineering JavaScript
PPTX
Object Oriented JavaScript
PPTX
Type script, for dummies
PDF
Joose @jsconf
PDF
[2019-07] GraphQL in depth (serverside)
PDF
Javascript
ODP
Ast transformations
PDF
Scala 2013 review
PDF
Say It With Javascript
ODT
Logic Equations Resolver J Script
PDF
Scala in practice
PDF
Java script object model
PDF
Modul Praktek Java OOP
PDF
Json.parse() in JavaScript
KEY
The Canvas API for Rubyists
PDF
Bindings: the zen of montage
ODP
Groovy Ast Transformations (greach)
Design patterns in javascript
Scala in practice
TypeScript Introduction
Engineering JavaScript
Object Oriented JavaScript
Type script, for dummies
Joose @jsconf
[2019-07] GraphQL in depth (serverside)
Javascript
Ast transformations
Scala 2013 review
Say It With Javascript
Logic Equations Resolver J Script
Scala in practice
Java script object model
Modul Praktek Java OOP
Json.parse() in JavaScript
The Canvas API for Rubyists
Bindings: the zen of montage
Groovy Ast Transformations (greach)
Ad

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Spectroscopy.pptx food analysis technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
The Rise and Fall of 3GPP – Time for a Sabbatical?
Diabetes mellitus diagnosis method based random forest with bat algorithm
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The AUB Centre for AI in Media Proposal.docx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
Per capita expenditure prediction using model stacking based on satellite ima...
Spectroscopy.pptx food analysis technology
NewMind AI Weekly Chronicles - August'25 Week I
MYSQL Presentation for SQL database connectivity
Programs and apps: productivity, graphics, security and other tools
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing

front-end dev

  • 1. Front-end dev by Paul Comanici (darkyndy)
  • 3. JavaScript is fun [] + [] = "" {} + {} = ?
  • 4. JavaScript is fun [] + [] = "" {} + {} = NaN 1 + "-1" = ?
  • 5. JavaScript is fun [] + [] = "" {} + {} = NaN 1 + "-1" = "1-1" NaN + [] = ?
  • 6. JavaScript is fun [] + [] = "" {} + {} = NaN 1 + "-1" = "1-1" NaN + [] = "NaN" 1 + NaN = ?
  • 7. JavaScript is fun [] + [] = "" {} + {} = NaN 1 + "-1" = "1-1" NaN + [] = "NaN" 1 + NaN = NaN
  • 8. JavaScript patterns function () { var x = 0; if (x === 1) { var y = 1; //execute other logic... } else if (x === 2) { var z = 2; //custom logic } }
  • 9. JavaScript patterns function () { Single var pattern var x = 0; Benefits: 1. Provides a single place to look for all the local if (x === 1) { variables needed by the function 2. Prevents logical errors when a variable is used var y = 1; before it's defined //execute other logic... 3. Helps you remember to declare variables and therefore minimize globals 4. Is less code (to type and to transfer over the wire) } else if (x === 2) { var z = 2; //custom logic } }
  • 10. JavaScript patterns var Animal = (function () { "use strict"; var type = "cat", defaultType = "cat"; return { getType: function () { return type; }, setType: function (customType) { customType = customType || defaultType; type = customType; } }; }());
  • 11. JavaScript patterns var Animal = (function () { "use strict"; var type = "cat", defaultType = "cat"; Module pattern return { getType: function () { return type; }, setType: function (customType) { customType = customType || defaultType; type = customType; } }; }());
  • 12. JavaScript patterns var Animal = (function () { "use strict"; var type = "cat", defaultType = "cat", getType = null, setType = null; getType = function () { return type; }; setType = function (customType) { customType = customType || defaultType; type = customType; }; return { getType: getType, setType: setType }; }());
  • 13. JavaScript patterns var Animal = (function () { "use strict"; var type = "cat", defaultType = "cat", Revealing module pattern getType = null, setType = null; getType = function () { return type; }; setType = function (customType) { customType = customType || defaultType; type = customType; }; return { getType: getType, setType: setType }; }());
  • 14. JavaScript patterns JavaScript namespacing and closures combined with module pattern base.js -> namespace creator car.js -> module
  • 15. JavaScript patterns (base.js) (function () { jQuery.each(nsp, function (j, n) { pp = make(n, pp); "use strict"; }); /*global window, jQuery, NK */ pp.__name__ = ns; if (typeof NK !== "undefined") { ret.push(pp); switch (ret.length) { return; case 0: } return null; window.NK = { case 1: return ret[0]; namespace : function (ns) { default: var ret = [], return ret; make = function (n, parent) { } } parent = parent || }; window; }()); if (!parent. hasOwnProperty(n)) { parent[n] = {}; } return parent[n]; }, nsp = ns.split("."), pp = null;
  • 16. JavaScript patterns (car.js) (function () { getPropr: function (p) { "use strict"; if (p in my) { return my[p]; /*global jQuery, NK */ } var my = { return null; type: "", }, color: "", setPropr: function (p, v) { origin: "", if (p in my) { init: function () { my[p] = v; my.type = "audi"; } } }, }, setColor: function (c) { obj = NK.namespace("NK.Car"); c = c || "black"; jQuery.extend(obj, { my.color = c; init: my.init, }, getPropr: my.getPropr, getColor: function () { setPropr: my.setPropr, getColor: my.getColor, return my.color; setColor: my.setColor, }, setFerrari: my.setFerrari setFerrari: function () { }); my.type = "ferrari"; }()); my.color = "red"; },
  • 17. JSLint 1. function test() { 2. a = new Array(); 3. a["d"] = "08"; 4. aa = [1,2,3]; 5. c = parseInt(a["d"]); 6. if (c == 8) { 7. for (var i=0;i<aa.length; i++){ 8. if (aa[i] == 2) console.log("true") 9. console.log("false") 10. } 11. } 12. }
  • 18. Google Developer Tools - console - debugger - JS breakpoints - DOM breakpoints - live JS edit - modify JS in debug - access to private methods in debug
  • 19. Google Developer Tools Suggestions for sites to debug?
  • 20. The end Thanks, Paul Comanici (darkyndy)