• Save
JavaScript Patterns to Cleanup your Code
Upcoming SlideShare
Loading in...5
×
 

JavaScript Patterns to Cleanup your Code

on

  • 11,983 views

This is a talk I gave at the AngleBrackets / DevIntersection conference in Vegas in April of 2013 covering JavaScript patterns that can be used to structure code and clean it up.

This is a talk I gave at the AngleBrackets / DevIntersection conference in Vegas in April of 2013 covering JavaScript patterns that can be used to structure code and clean it up.

Statistics

Views

Total Views
11,983
Views on SlideShare
3,972
Embed Views
8,011

Actions

Likes
7
Downloads
0
Comments
0

52 Embeds 8,011

http://weblogs.asp.net 4607
http://localhost 1249
http://feedly.com 706
http://feeds2.feedburner.com 690
http://www.newsblur.com 135
http://feedreader.com 101
http://wahlin6.rssing.com 70
http://newsblur.com 62
http://www.inoreader.com 55
https://weblogs.asp.net 43
http://digg.com 41
http://beta.asp.net 32
https://feedly.com 30
http://www.feedspot.com 28
http://www.directrss.co.il 28
http://127.0.0.1 21
https://www.newsblur.com 14
http://www.tuicool.com 11
http://reader.aol.com 10
http://rss.ysatech.com 8
http://wrwpf.codeplex.com 6
https://entropysoftware.noip.me 5
http://www.hanrss.com 5
http://dev.newsblur.com 4
http://weblogs.aspnet06.orcsweb.com 4
http://www.newsisfree.com 4
http://cloud.feedly.com 4
http://tiriss.com 3
https://bazqux.com 3
http://silverreader.com 3
https://www.inoreader.com 3
http://translate.googleusercontent.com 2
http://beta.inoreader.com 2
http://sommaweb.com.br 2
http://feeds.feedburner.com 2
https://twitter.com 2
http://webcache.googleusercontent.com 1
http://news.google.com 1
http://www.verious.com 1
http://rpi.uddebo.net 1
http://www.feedvault.com 1
http://ams.activemailservice.com 1
http://hivereader.com 1
http://www.newsfolders.com 1
http://feedspot.com 1
http://www.rssmicro.com 1
https://reader.aol.com 1
http://yoleoreader.com 1
http://mail01.ori.net 1
https://www.commafeed.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Discuss what function spaghetti code is (simply listing function after function without a container)
  • Uses standards-based CSS
  • Uses standards-based CSS
  • Uses standards-based CSS
  • Uses standards-based CSS
  • setVal = function (val) {           this.currNumberCtl.innerHTML = val;       },       setEquation = function (val) {           this.eqCtl.innerHTML = val;       },       clearNumbers = function () {           lastNumber = null;           equalsPressed = operatorSet = false;           setVal.call(this, '0');           setEquation.call(this, '');       },
  • function extend(o,p){ for(prop in p){o.prototype[prop]=p[prop]; }; return o;}Then:extend(calculator, {       numberClick: numberClick,       setOperator: setOperator,       clearNumbers: clearNumbers})Keith Chadwick

JavaScript Patterns to Cleanup your Code JavaScript Patterns to Cleanup your Code Presentation Transcript

  • JavaScript Patterns to Clean Up Your Code Dan Wahlin
  • This presentation is based on an online training course available at http://www.pluralsight.com
  •       View slide
  •        View slide
  •      
  •      
  • function myNonClosure() { var date = new Date(); return date.getMilliseconds(); } Variable lost after function returns
  • function myClosure() { var date = new Date(); //nested function return function () { return date.getMilliseconds(); }; } Variable stays around even after function returns
  •      
  •    var calc = { tempValue: 1, add: function(x, y){ return x + y; } };
  •  var my = my || {};
  • my.calc = { tempValue: 1, add: function(x, y) { return x + y; } };
  •      
  •         
  • var Calculator = function(eq) { this.eqCtl = document.getElementById(eq); }; Calculator.prototype = { add: function (x, y) { var val = x + y; this.eqCtl.innerHTML = val; } }; var calc = new Calculator('eqCtl'); calc.add(2,2);
  •      
  •        
  • var calculator = function(eq) { var eqCtl = document.getElementById(eq), doAdd = function(x,y) { var val = x + y; eqCtl.innerHTML = val; }; return { add: doAdd }; //Expose public member }('eqCtl'); calculator.add(2,2);
  •      
  •          
  • var Calculator = function (eq) { this.eqCtl = document.getElementById(eq); }; Calculator.prototype = function() { var doAdd = function (x, y) { var val = x + y; this.eqCtl.innerHTML = val; }; return { add : doAdd }; }(); var calc = new Calculator('eqCtl'); calc.add(2,2);
  •       
  • Sample Code, Book, and Videos http://tinyurl.com/StructuringJSCode
  • http://weblogs.asp.net/dwahlin