<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>desalasworks</title>
  <link>https://desalasworks.com/</link>
  <atom:link href="https://desalasworks.com/feed/" rel="self" type="application/rss+xml" />
  <description>a portfolio of work by steven de salas</description>
  <language>en</language>
  <lastBuildDate>Tue, 08 Oct 2024 16:26:12 GMT</lastBuildDate>
  <item>
    <title>Stuart</title>
    <link>https://desalasworks.com/stuart/</link>
    <guid>https://desalasworks.com/stuart/</guid>
    <pubDate>Tue, 08 Oct 2024 16:26:12 GMT</pubDate><category>Cloud</category><category>Microservices</category><category>Mobile</category>
    <description>&lt;p&gt;&lt;em&gt;Building real-time core backend infrastructure for Pan-European delivery logistics.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt; &lt;img class=&quot;alignnone size-full wp-image-2432&quot; src=&quot;https://desalasworks.com/stuart/420x337.2-2.jpg&quot; alt=&quot;&quot; width=&quot;420&quot; height=&quot;337&quot; /&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Steven helped build and launch Stuart&#39;s mobile backend streaming functionality providing realtime platform updates, routing millions of delivery requests every week across 100s of European cities. Helping Stuart maintain its reputation for hyper-reliability as well as introducing improvements to company-wide engineering, QA and security practice.&lt;/p&gt;
&lt;h2&gt;Tech Stack&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Redis PubSub, Event-based architecture, WebSocket protocol, Node.js, Express, TypeScript, OpenAPI, Kubernetes, AWS, DevOps, Prometheus, Thanos, Grafana. Kafka. Auto scaling. Graceful shutdown. Test automation. K6. SonarCloud. ZAP Scan. Authentication. JWT. ECDSA Web crypto API, Observability dashboards. Mentoring.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Key Deliverables&lt;/h2&gt;
&lt;p&gt;The mobile app team was looking to scale its functionality but was being held back by downtime risk during deployments of a backend legacy component. The key deliverable to unblock them was to extract the core message streaming functionality so that it could be iterated and built upon, putting it into a separate &lt;strong&gt;Kubernetes&lt;/strong&gt; hosted service, built using &lt;strong&gt;Node.js&lt;/strong&gt; and &lt;strong&gt;TypeScript &lt;/strong&gt;and &lt;strong&gt;WebSockets&lt;/strong&gt;, with &lt;strong&gt;Redis&lt;/strong&gt; as the pub/sub fanout mechanism.&lt;/p&gt;
&lt;p&gt;The project was a success. Delivered on time and within budget working with a small high-impact team of engineers. In addition to the project goals Steven also worked on creating several other APIs (feature flags, device log streaming) and made company-wide improvements to DevEx, QA and Security practice.&lt;/p&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;Here is feedback on Linkedin. From &lt;a href=&quot;https://www.linkedin.com/in/sdesalas/details/recommendations/&quot;&gt;Pau Picas,&lt;/a&gt; &lt;a href=&quot;https://www.linkedin.com/feed/update/urn:li:activity:7193603162241433600?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7193603162241433600%2C7193661243746881536%29&amp;amp;dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287193661243746881536%2Curn%3Ali%3Aactivity%3A7193603162241433600%29&quot;&gt;Sergi&lt;/a&gt; and &lt;a href=&quot;https://www.linkedin.com/feed/update/urn:li:activity:7252324946499035136?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7252324946499035136%2C7252373527750713344%29&amp;amp;dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287252373527750713344%2Curn%3Ali%3Aactivity%3A7252324946499035136%29&#92;&quot;&gt;Rafa&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/in/paupicas?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base_recommendations_details%3BShsjHE4CSfePxCQIWGhIvg%3D%3D&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-2462&quot; src=&quot;https://desalasworks.com/stuart/pau1.png&quot; alt=&quot;&quot; width=&quot;454&quot; height=&quot;79&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Steven is an outstanding engineer. In the short time he was at Stuart, Steven was able to &#39;hit the ground running&#39; and made a significant contribution by implementing a notification system to allow the real-time processing of delivery requests in the mobile app. This ensured that critical data was reliably processed, and performance-tested at scale, paving the path for us to reliably scale our platform.&lt;/p&gt;
&lt;p&gt;Steven&#39;s technical proficiency in Node.js and backend APIs, coupled with his ability to collaborate across teams, made him an invaluable asset. I highly recommend him for any role that values innovation, problem-solving, and teamwork.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/in/sergicastellsague/&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-2461&quot; src=&quot;https://desalasworks.com/stuart/Sergi.png&quot; alt=&quot;&quot; width=&quot;287&quot; height=&quot;69&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;It was a great pleasure having you onboard. Thank you for all your great contributions and leadership Esteban!&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/feed/update/urn:li:activity:7252324946499035136?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7252324946499035136%2C7252373527750713344%29&amp;amp;dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287252373527750713344%2Curn%3Ali%3Aactivity%3A7252324946499035136%29&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-2491&quot; src=&quot;https://desalasworks.com/stuart/Rafa.png&quot; alt=&quot;&quot; width=&quot;418&quot; height=&quot;65&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Esteban is just awesome. My experience working with him is really positive.&lt;br /&gt;
I am extremely confident that he will make a great impact wherever he is helping other people achieve their vision.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Newcross Healthcare</title>
    <link>https://desalasworks.com/newcross-healthcare/</link>
    <guid>https://desalasworks.com/newcross-healthcare/</guid>
    <pubDate>Tue, 08 Oct 2024 15:15:51 GMT</pubDate><category>Mobile</category><category>Cloud</category><category>Microservices</category><category>Web Applications</category>
    <description>&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2412&quot; src=&quot;https://desalasworks.com/newcross-healthcare/420x337.2.jpg&quot; alt=&quot;&quot; width=&quot;420&quot; height=&quot;350&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Steven spent 18 months working as Lead Engineer for HFA team. &quot;Uber for healthcare workers&quot;. Processing payments for thousands of health workers in both home and residential care setting. Focused on performance and stability fixes, CICD pipelines, upskilling new engineers, removing blockers, backend deployments and troubleshooting/extending system.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Technology Stack&lt;/h2&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2417&quot; src=&quot;https://desalasworks.com/newcross-healthcare/techstack.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Express, FeathersJS, Kafka, Sequelize ORM, Promises, Asyc/Await, ES2021, RESTful APIs, Jest, React, Babel, Webpack, Redis, RabbitMQ, SQL Server, DB Replication, Bitbucket, Github Actions, Monorepos, Docker, Kubernetes, Test Automation, GitOps, DevOps, Jenkins, Bash, AWS, EC2, S3, SQS, Serverless, Lambdas, CloudFront, CloudFormation, SNS, IAM, Load Balancing, SonarQube, SSL/TLS Certificates, New Relic Analytics. OAuth, Single Sign-On. Performance optimization. Debugging Production. Code Reviews and mentoring.&lt;/p&gt;
&lt;h2&gt;Key Deliverables&lt;/h2&gt;
&lt;p&gt;Steven joined Newcross at a critical time of change. The initial intention was for him to continue the work of previous engineers in a small team maintaining a highly impactful healthcare platform that helped to improve people&#39;s lives and was very much in demand. However it quickly became evident that the tech debt accumulated over years made the platform hard to maintain, let alone grow the business.&lt;/p&gt;
&lt;p&gt;Steven went from being a Senior Engineer in a team of 2, to interviewing and leading a team of 10 engineers and testers. All the while helping to mentor and upskill new hires, removing blockers, automate deployments, track down issues in production, improve the platform to make sure it was performant and reliable, and being responsible for cross-functional collaboration.&lt;/p&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;Here is feedback on Linkedin.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/in/harinder-singh-6b174326/&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-2464&quot; src=&quot;https://desalasworks.com/newcross-healthcare/harinder.png&quot; alt=&quot;&quot; width=&quot;396&quot; height=&quot;73&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Working with Steven was great. He joined Newcross at a critical time and quickly became an essential part of the backend team. He then took charge of our platform backend and made significant contributions towards performance improvements, build automation, bug fixes and setting up a strong engineering practice within the team. He also helped in laying the foundations of migrating Monolith to Microservices. Very happy to recommend him.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2493&quot; src=&quot;https://desalasworks.com/newcross-healthcare/Stuart.png&quot; alt=&quot;&quot; width=&quot;533&quot; height=&quot;61&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Esteban is one of the most inspiring engineers I’ve ever worked with. His “Sherlock Holmes”-esqe team presentations, where he tracked down the most elusive bugs, were legendary at Newcross and had people actually applauding! Incredibly smart and a genuine pleasure to work with, his superpower is inspiring and lifting the whole team around him. I can’t recommend Mr De Salas highly enough.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Startup Unicorns</title>
    <link>https://desalasworks.com/startup-unicorns/</link>
    <guid>https://desalasworks.com/startup-unicorns/</guid>
    <pubDate>Fri, 02 Dec 2022 20:24:59 GMT</pubDate><category>Games</category><category>Print</category>
    <description>&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2439&quot; src=&quot;https://desalasworks.com/startup-unicorns/niceimage3.plus_.jpg&quot; alt=&quot;&quot; width=&quot;1600&quot; height=&quot;900&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A Kickstarter campaign by Steven de Salas.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;2-6 player competitive card game for people of all ages.&lt;/em&gt;&lt;/p&gt;
&lt;h2 class=&quot;page-anchor&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-2387&quot; src=&quot;https://desalasworks.com/startup-unicorns/site-1.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;351&quot; /&gt;&lt;/h2&gt;
&lt;h2 class=&quot;page-anchor&quot;&gt;What is Startup Unicorns?&lt;/h2&gt;
&lt;p&gt;&lt;span class=&quot;bold&quot;&gt;START-UP UNICORNS&lt;/span&gt; is a competitive 2-6 player &lt;span class=&quot;bold&quot;&gt;CARD GAME&lt;/span&gt; aimed at players &lt;span class=&quot;bold&quot;&gt;OF ALL AGES&lt;/span&gt; that aims to recreate the &lt;span class=&quot;bold&quot;&gt;EXCITEMENT&lt;/span&gt; of turning an awesome idea into a successful startup.&lt;/p&gt;
&lt;p&gt;You will be competing with your friends to &lt;span class=&quot;bold&quot;&gt;FIND INVESTORS,&lt;/span&gt; &lt;span class=&quot;bold&quot;&gt;BUILD A TEAM,&lt;/span&gt; and &lt;span class=&quot;bold&quot;&gt;SABOTAGE EACH OTHER&lt;/span&gt; to be the first person turn their startup into a &lt;span class=&quot;bold&quot;&gt;MILLION DOLLAR&lt;/span&gt; business!&lt;/p&gt;
&lt;p&gt;Check it out:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://startupunicorns.org/&quot;&gt;https://startupunicorns.org &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2398&quot; src=&quot;https://desalasworks.com/startup-unicorns/3d.twoboxes.600.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;430&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Each game one takes around &lt;span class=&quot;bold&quot;&gt;20-30 MINUTES&lt;/span&gt; depending on the number of players. They are &lt;span class=&quot;bold&quot;&gt;FAST&lt;/span&gt; and &lt;span class=&quot;bold&quot;&gt;FUN&lt;/span&gt;. You&#39;ll be wanting to &lt;span class=&quot;bold&quot;&gt;COME BACK FOR MORE&lt;/span&gt;!&lt;/p&gt;
&lt;h2 class=&quot;page-anchor&quot;&gt;Package Contents&lt;/h2&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2394&quot; src=&quot;https://desalasworks.com/startup-unicorns/cards.new_.500px.jpg&quot; alt=&quot;&quot; width=&quot;500&quot; height=&quot;208&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The basic game comes as a &lt;span class=&quot;bold&quot;&gt;SET OF 108 CARDS &lt;/span&gt;and &lt;span class=&quot;bold&quot;&gt;INSTRUCTIONS &lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1 x Set of INSTRUCTIONS (English &amp;amp; Spanish)&lt;/li&gt;
&lt;li&gt;12 x &quot;COMPANY&quot; cards&lt;/li&gt;
&lt;li&gt;24 x &quot;TECH&quot; cards&lt;/li&gt;
&lt;li&gt;16 x &quot;MARKETING&quot; cards&lt;/li&gt;
&lt;li&gt;16 x &quot;PRODUCT&quot; cards&lt;/li&gt;
&lt;li&gt;12 x &quot;INVESTOR&quot; cards&lt;/li&gt;
&lt;li&gt;10 x &quot;ADVANTAGE&quot; cards&lt;/li&gt;
&lt;li&gt;10 x &quot;SABOTAGE&quot; cards&lt;/li&gt;
&lt;li&gt;6 x &quot;QUICK GUIDE&quot; cards&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Gallery&lt;/h2&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-large wp-image-2390&quot; src=&quot;https://desalasworks.com/startup-unicorns/IMG_20230914_121223-600x338.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;338&quot; /&gt; &lt;img class=&quot;alignnone size-large wp-image-2391&quot; src=&quot;https://desalasworks.com/startup-unicorns/IMG_20230914_121332-600x338.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;338&quot; /&gt; &lt;img class=&quot;alignnone size-large wp-image-2392&quot; src=&quot;https://desalasworks.com/startup-unicorns/IMG_20230914_110018642-600x338.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;338&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>LetMePark</title>
    <link>https://desalasworks.com/letmepark/</link>
    <guid>https://desalasworks.com/letmepark/</guid>
    <pubDate>Thu, 19 Nov 2020 20:22:43 GMT</pubDate><category>Cloud</category><category>Microservices</category><category>Voice</category><category>Mobile</category><category>Startups</category>
    <description>&lt;p&gt;&lt;em&gt;Building smart cities by connecting vehicles with their environment.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2486&quot; src=&quot;https://desalasworks.com/letmepark/420x337-1.jpg&quot; alt=&quot;&quot; width=&quot;420&quot; height=&quot;337&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Founding Engineer&lt;/h3&gt;
&lt;p&gt;Steven had a pivotal role designing and building the core platform infrastructure for this startup in the urban mobility space. Maximizing IT resource use and speed-to-market with low-cost, stable, high-performance infrastructure.&lt;/p&gt;
&lt;p&gt;As the platform grew in complexity and demand, Steven became CTO in order to encompass the leadership of a growing technology team of engineers, designers and testers.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2301&quot; src=&quot;https://desalasworks.com/letmepark/lmp-offering3.jpg&quot; alt=&quot;&quot; width=&quot;1300&quot; height=&quot;837&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Backend Architecture &amp;amp; Integration&lt;/h3&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2308&quot; src=&quot;https://desalasworks.com/letmepark/cloud-computing-architecture.notext.jpg&quot; alt=&quot;&quot; width=&quot;750&quot; height=&quot;302&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Integration with multiple third-party parking provider services, allowing real-time price and availability checks, bookings and automated parking notifications.&lt;/p&gt;
&lt;p&gt;The skills used were: Google Cloud, Amazon Web Services, Build Automation, JavaScript, Node.js, API Development, MongoDB, DevOps, Docker, ECS, Gitlab, Security/Cryptography, Bash/Unix scripting, MQTT, Nginx, PCI Payment Processing (Paycomet TPV) and Test Automation.&lt;/p&gt;
&lt;h3&gt;Web &amp;amp; Mobile Hybrid App&lt;/h3&gt;
&lt;p&gt;Development and enhancements to a Vue.js (Nuxt) web app doubling up as a hybrid web-view app for iOS and Android platforms, allowing clients to carry their parking experience anywhere inside their pocket.&lt;/p&gt;
&lt;h3&gt;&lt;img class=&quot;alignnone wp-image-2311&quot; src=&quot;https://desalasworks.com/letmepark/webapp2.png&quot; alt=&quot;&quot; width=&quot;450&quot; height=&quot;420&quot; /&gt;&lt;/h3&gt;
&lt;h3&gt;Voice Assistant Integration&lt;/h3&gt;
&lt;p&gt;Steven worked on integrating the Alexa Skill that allows users to search and book whilst driving their car.&lt;/p&gt;
&lt;p&gt;This included providing all necessary backend APIs and authentication/user flows as well as the technology platform capable of live multi-provider search and bookings, including live monitoring.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2313&quot; src=&quot;https://desalasworks.com/letmepark/alexa-mobile-concept.jpg&quot; alt=&quot;&quot; width=&quot;800&quot; height=&quot;533&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Payment Processing&lt;/h3&gt;
&lt;p&gt;Steven also integrated the customer Credit Card capture and payment processing flows for both bookings and automated parkings.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2318&quot; src=&quot;https://desalasworks.com/letmepark/payment.png&quot; alt=&quot;&quot; width=&quot;760&quot; height=&quot;450&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/in/ulianatorkunova?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base_recommendations_details%3BShsjHE4CSfePxCQIWGhIvg%3D%3D&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-2474&quot; src=&quot;https://desalasworks.com/letmepark/uliana.png&quot; alt=&quot;&quot; width=&quot;430&quot; height=&quot;113&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;We were lucky to find Steven. He was able to work under time-pressure and with a constantly changing set of priorities to deliver much of the core IT infrastructure for our Mobility-based startup. Later growing in his role to encompass the leadership of a growing development team for our unique solution.&lt;/p&gt;
&lt;p&gt;Apart from being disciplined, motivated and highly knowledgeable, he barely had much of an ego, always willing to help junior developers and &#39;wear many hats&#39; as needed, explaining technical problems and opportunities in plain English to make sure that the leadership was informed at every step of the choices we had available to us.&lt;/p&gt;&lt;/blockquote&gt;
</description>
  </item>
  <item>
    <title>Asynchronous Neural Networks in JavaScript</title>
    <link>https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/</link>
    <guid>https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/</guid>
    <pubDate>Tue, 06 Mar 2018 06:59:57 GMT</pubDate><category>Code</category><category>IoT</category>
    <description>&lt;p&gt;&lt;img class=&quot;size-large wp-image-2166 aligncenter&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/IMG_20170608_174532234-600x338.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;338&quot; /&gt;&lt;/p&gt;
&lt;p&gt;For the past few months I’ve been trying to get &lt;a href=&quot;http://github.com/sdesalas/robotics&quot;&gt;some of my robots&lt;/a&gt; to roam around the house with a mind of their own, learning as they go. It turns out that the task is harder than I thought.&lt;/p&gt;
&lt;p&gt;The main issue is paralell signal processing.&lt;/p&gt;
&lt;p&gt;To illustrate: a single robot will have usually 3-5 sensors that collect information on the world around it. I&#39;m particularly interested in ambient light as i want it to be able to recharge its batteries with a mini solar panel if it needs to, but i also have some useful options for collision detection, orientation and WiFi triangulation.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;size-large wp-image-2164 aligncenter&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/basic-premise-600x351.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;351&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;First attempt, enter the matrix&lt;/h3&gt;
&lt;p&gt;I originally attempted a weighted relational matrix of inputs to outputs. Like a chequers board where each square starts off with one piece that represents the strength of the relationship between an input and an output. To simulate learning, I would stack extra pieces on a square, for example to reinforce past choices, making it more likely to get picked in subsequent iterations. I called the engine &lt;a href=&quot;https://github.com/sdesalas/fusspot/tree/7275a26f52e690dc8d54ce7c784e7f724be1901a&quot;&gt;fusspot&lt;/a&gt;, which I thought was a suitable name given that this algorithm could be trained but in the end, choices were always fuzzy and random.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/sdesalas/fusspot/67619b6af2224606899c54497f540d2bde404417/learning.png&quot; alt=&quot;chequers&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This worked, in a fashion. I could train the engine by modifying the strength of each relationship, making subsequent choices more likely to be biased by training, but it was a terrible solution when trying to implement it in practice.&lt;/p&gt;
&lt;p&gt;The main problem is that this solution does not take context into account, and it turns out context is everything – you can’t rely on a single input channel (such as IR sensor) to determine the choices a robot can make (stop, turn, keep going), it takes a wholistic approach that integrates data from all the sensors at the same time.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Context is everything. You can&#39;t rely on a single input channel, it takes a wholistic approach that integrates data from all the sensors &lt;em&gt;at the same time&lt;/em&gt;.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I got to a point where trying to break down the problem further wasn’t getting me anywhere. So I decided to look around and see what other people had done.&lt;/p&gt;
&lt;h3&gt;Video games and artificial gardening.&lt;/h3&gt;
&lt;p&gt;By this point I had done a bit of reading on &lt;a href=&quot;https://en.wikipedia.org/wiki/Artificial_neural_network&quot;&gt;Artificial Neural Networks&lt;/a&gt; and decided that this was roughly where I was heading.&lt;/p&gt;
&lt;p&gt;This led me into the world of video games. I’ve played plenty of games myself and know that game developers are at the leading edge of AI.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Artificial_intelligence_(video_games)&quot;&gt;The wikipedia article&lt;/a&gt; inspired me to look a bit more into a game called &lt;a href=&quot;https://aigamedev.com/open/review/creatures-ai/&quot;&gt;Creatures&lt;/a&gt; written by a guy called &lt;a href=&quot;https://en.wikipedia.org/wiki/Steve_Grand_(roboticist)&quot;&gt;Steve Grand&lt;/a&gt;. Steve dropped off the face of the earth a few years ago through a self-inflicted &lt;a href=&quot;https://www.kickstarter.com/projects/1508284443/grandroids-real-artificial-life-on-your-pc&quot;&gt;kickstarter project&lt;/a&gt; &lt;a href=&quot;https://docs.google.com/document/d/1WDKL-2vihuaRLHjsZCxtr6qj0oCe8lV82inwmCVrjBs/pub&quot;&gt;gone wrong&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;size-large wp-image-2165 aligncenter&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/creatures.stevegrand-600x336.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;336&quot; /&gt;&lt;/p&gt;
&lt;p&gt;But before he did so, he wrote an excellent book called &lt;a href=&quot;http://www.goodreads.com/book/show/304444.Creation&quot;&gt;Creation, Life and how to make it&lt;/a&gt;, where he details some of the techniques he used, as well a zen-like philosophical outlook on artificial life powerful enough to blow my socks off and turn upside down all my notions of what AI is and should be about:&lt;/p&gt;
&lt;p&gt;All life, both biological and artificial, are series of emergent patterns that persist longer than others, in other words, certain patterns of interaction between components (cells usually, though these are also made of patterns of interaction between cellular components and so on to the atomic level) happen to be more successful in their environment and thus persist through time.&lt;/p&gt;
&lt;p&gt;The beauty here is that life is a set of emergent patterns, rather than the components of which its made of, or the behaviour that arises from their interaction. The best humans can strive for is &lt;em&gt;creating the conditions&lt;/em&gt; that would allow such patterns to emerge, for example by defining the underlying components and encouraging certain patterns of behaviour over others. Think of it as artificial gardening..&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The beauty here is that life is a set of emergent patterns, rather than the components of which its made of, or the behaviour that arises from their interaction.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h3&gt;Neural Networks, Rebooted.&lt;/h3&gt;
&lt;p&gt;So. I started modelling a neural network in JavaScript.&lt;/p&gt;
&lt;p&gt;Its not hard. Just an array of nodes, each containing another array of links to other nodes. With the added catch that each link to another node has a weight between 0 and 1, which determines if the onward connection should be fired during a chain-reaction event. My &lt;a href=&quot;https://github.com/sdesalas/fusspot/blob/45418ede3548f03501102eb69c5ab3f5481c331c/NeuralNetwork.js&quot;&gt;first commit&lt;/a&gt; was 100 lines long. 60 if you remove comments and whitespacing.&lt;/p&gt;
&lt;p&gt;Since I was trying to accurately model the biological system in our own brains (rather than a mathematical abstraction), I noticed my own gut telling me to add a slight delay between firing neurons. It seems natural really, it generally &lt;a href=&quot;https://en.wikipedia.org/wiki/Refractory_period_(physiology)&quot;&gt;takes a whole millisecond&lt;/a&gt; to fire off the next neuron inside our brains, so the signal is never going to travel all the way across the brain instantly.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;size-full wp-image-2171 aligncenter&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/Neuron.Class.png&quot; alt=&quot;&quot; width=&quot;432&quot; height=&quot;247&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This solved my problem rather neatly. I had several input streams from each sensor that needed to be integrated, and I needed something that could be trained on a particular input, &lt;em&gt;while taking into account all the other inputs&lt;/em&gt;, or even a changing set of inputs&lt;em&gt;. &lt;/em&gt;Something that could behave more like a normal brain and create an intricately timed set of reactions to an input (think of the muscles involved in picking up your phone), or integrate an input with itself (by having a signal that loops around).&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;I noticed my own gut telling me to add a slight delay between firing neurons. It seems natural really ... the signal its never going to travel all the way across the brain instantly.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I also researched the interleaving of signal patterns in real neurons and came up with a spiking model that combined multiple upstream signals before firing a signal downstream.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2206&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/signal-buildup.gif&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;323&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Chaos and the game of life&lt;/h3&gt;
&lt;p&gt;This was all confusing as hell so I needed to visualize my network in order to understand what it was doing.&lt;/p&gt;
&lt;p&gt;Thankfully JavaScript is a great language for that, there are tons of libraries out there for visualization and thanks to V8 and the NodeJS ecosystem you can run the same code on the browser as you would a command line executable. I used &lt;a href=&quot;http://browserify.org/&quot;&gt;browserify&lt;/a&gt; to require my modules on a browser page and &lt;a href=&quot;http://visjs.org/&quot;&gt;viz.js&lt;/a&gt; to perform visualizations using HTML5 &lt;code&gt;&amp;lt;canvas/&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The result was intriguing. I noticed all sorts of patterns, travelling waves, and oscillations taking place when a neuron was fired. It was utter chaos but it was also mesmerizing.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://sdesalas.github.io/fusspot/?shape=sausage&amp;amp;size=120&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-2055&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/fusspot.gif&quot; alt=&quot;&quot; width=&quot;611&quot; height=&quot;624&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The result was intriguing. It was utter chaos, but it was also mesmerizing.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I felt I was on to something. After all &lt;a href=&quot;http://musetude.com/brain-r-d/brain-frequencies/&quot;&gt;electrical wave patterns&lt;/a&gt; are an inherent part of the human brain. So why do prevailing models of neural networks ignore them?&lt;/p&gt;
&lt;p&gt;It turns out that I was building something called a &lt;a href=&quot;https://en.wikipedia.org/wiki/Spiking_neural_network&quot;&gt;Spiking Neural Network&lt;/a&gt;, the so-called 3rd generation of neural networks that more closely emulate their biological cousins, and which encode information in patterns of signals.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2177&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/3rd-gen-neurons.gif&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;384&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I tried different network shapes, a ball, a sausage and a dounught. All produced interesting variations. Jonathan, a colleague at work, said it reminded him of &lt;a href=&quot;https://en.wikipedia.org/wiki/Conway&#39;s_Game_of_Life&quot;&gt;Conway’s Game of Life&lt;/a&gt;. I had to agree with him.&lt;/p&gt;
&lt;h3&gt;Now in 3D&lt;/h3&gt;
&lt;p&gt;It took some extra modelling to come up with a good visualization that would let me understand what was going on, my original 2D library could only visualize around 300 neurons before falling over, using 3D I could increase that to a few thousands.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/sdesalas/botbrains&quot;&gt;&lt;img src=&quot;https://raw.githubusercontent.com/sdesalas/botbrains/master/brain-3d.gif&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I called the newly born library &lt;a href=&quot;https://github.com/sdesalas/botbrains&quot;&gt;botbrains&lt;/a&gt;, and used a combination of a &lt;a href=&quot;https://www.npmjs.com/package/@sdesalas/3d-force-graph&quot;&gt;3D Force Graph&lt;/a&gt; in WebGL for rendering the network, &lt;a href=&quot;https://en.wikipedia.org/wiki/WebSocket&quot;&gt;WebSockets&lt;/a&gt; for client/server interaction, and &lt;a href=&quot;https://nodejs.org/&quot;&gt;node.js&lt;/a&gt; for running the neural network on the back-end so it could integrate via USB Serial to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Arduino&quot;&gt;Arduino&lt;/a&gt; microcontroller running my motors and collecting data from sensors.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Machine Learning, for signal patterns.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Next challenge came from learning. I had to find a way to make the robot marginally smarter over time. After all its not very useful if your robot keeps bumping into the wall.&lt;/p&gt;
&lt;p&gt;Thankfully, plenty of people had already worked out the answer. Or rather two answers, really. You either use &lt;a href=&quot;https://en.wikipedia.org/wiki/Reinforcement_learning&quot;&gt;reinforcement&lt;/a&gt; or &lt;a href=&quot;https://www.youtube.com/watch?v=Ilg3gGewQ5U&quot;&gt;back-propagation&lt;/a&gt;. Both good approaches, but since my network was asynchronous, working out the &lt;a href=&quot;https://en.wikipedia.org/wiki/Loss_function&quot;&gt;loss-function&lt;/a&gt; for back-propagation was a real headache (I had to backtrack in time taking into account competing signals) and besides I didn&#39;t want to depend on layers as I wanted all the richness of signal patterns that different shapes of neural network could create.&lt;/p&gt;
&lt;p&gt;The biological answer here was reinforcement, aka &quot;&lt;a href=&quot;https://en.wikipedia.org/wiki/Long-term_potentiation&quot;&gt;Long Term Potentiation&lt;/a&gt;&quot;. So I went with that. Later I found out that AlphaZero, the &lt;a href=&quot;https://www.theguardian.com/technology/2017/dec/07/alphazero-google-deepmind-ai-beats-champion-program-teaching-itself-to-play-four-hours&quot;&gt;current AI chess champion&lt;/a&gt; used reinforcement too so that made me feel much better about my choice.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2182&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/alphazero.jpg&quot; alt=&quot;&quot; width=&quot;794&quot; height=&quot;556&quot; /&gt;&lt;/p&gt;
&lt;p&gt;So, how to implement reinforcement learning?&lt;/p&gt;
&lt;p&gt;Well, its not so hard really, though it took several iterations. The basic premise was to reinforce synapses that fired recently whenever the robot does something good (like avoid an obstacle), and to weaken synapses that fired recently whenever something bad happens.&lt;/p&gt;
&lt;p&gt;Although pretty close, this wasn&#39;t enough on its own, as the network would either overload or fail to connect altogether, so after a fair bit of testing I worked out that the most elegant model was to maintain the network weight constant by spreading out any positive or negative changes over the remaining unused synapses, so effectively during learning I would strengthen &#39;successful&#39; connections while weakening all the other ones, reversing the process for negative reinforcement.&lt;/p&gt;
&lt;p&gt;I also added a tendency for synapse weights to decay towards their starting weight with each learning iteration, as well as strengthening unused synapses randomly whenever negative reinforcement is applied (ie, sometimes the solution to the problem can be found by using neural pathways that have never been used before).&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2179&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/learning.png&quot; alt=&quot;&quot; width=&quot;840&quot; height=&quot;283&quot; /&gt;Long-term memory was a problem, and still is to this day though its getting better.&lt;/p&gt;
&lt;p&gt;I added the ability for synapses to contain both &#39;short-term&#39; and &#39;long-term&#39; weights, both of which are influenced by the other.  I pinched this idea from Steve Grand, which I found an incredibly simple and powerful solution to long-term memory.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2180&quot; src=&quot;https://desalasworks.com/article/asynchronous-neural-networks-in-javascript/long-term.png&quot; alt=&quot;&quot; width=&quot;615&quot; height=&quot;337&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Now all I had to do was to plug my robot into it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>DarklyLabs LaserWeb</title>
    <link>https://desalasworks.com/darklylabs-laserweb/</link>
    <guid>https://desalasworks.com/darklylabs-laserweb/</guid>
    <pubDate>Thu, 01 Jun 2017 07:32:06 GMT</pubDate><category>UI</category><category>Desktop Application</category><category>IoT</category>
    <description>&lt;p&gt;Steven was a one-man team building on top of open source &quot;LaserWeb&quot; software, automating and simplifying complex user flows to bring laser cutting to the beginner user.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-large wp-image-2121&quot; src=&quot;https://desalasworks.com/darklylabs-laserweb/emblaser2-600x359.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;359&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This project involved full SDLC, building a simple and easy-to-use JavaScript wizard interface for the Emblaser2 laser cutter &amp;amp; engraver, which went from design to delivery in 6 weeks.&lt;/p&gt;
&lt;p&gt;A challenging and very enjoyable project using NodeJS, JavaScript (ES6), Electron (Win/OSX Desktop app), Embedded, Computer Numerical Control (CNC/GCODE), WebWorkers, USB serialport, Github, CI / build automation (Travis, Appveyor), CSS, DOM Events, Webpack, React, Redux, Socket IO, WebGL 3D.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone wp-image-2122 size-full&quot; src=&quot;https://desalasworks.com/darklylabs-laserweb/wizard.video_.gif&quot; alt=&quot;&quot; width=&quot;1004&quot; height=&quot;646&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>SEEK Role Requirements</title>
    <link>https://desalasworks.com/seek-role-requirements/</link>
    <guid>https://desalasworks.com/seek-role-requirements/</guid>
    <pubDate>Sun, 30 Apr 2017 05:18:49 GMT</pubDate><category>Web Applications</category><category>Cloud</category><category>Microservices</category>
    <description>&lt;p&gt;Full Stack JavaScript contract role working on SEEK User Interfaces and AWS hosted API’s.&lt;/p&gt;
&lt;p&gt;Steven joined the &#39;Role Requirements&#39; team to help deliver great candidate matching. Millions of job applications are now getting scored and ranked for role suitability every year, resulting in significant time savings to users of the SEEK platform.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone wp-image-2222 size-full&quot; src=&quot;https://desalasworks.com/seek-role-requirements/Seek.hirer_.platform.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;810&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The majority of the work involved various enhancements to the back-end capability in the form of AWS-hosted micro-service APIs, and some user interface updates to accommodate improvements to job-seeker and hirer experiences.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-2220&quot; src=&quot;https://desalasworks.com/seek-role-requirements/seek-api-stats.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;311&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Working in a Continuosly Deployed, Agile environment with Node.Js, Angular, Knockout, Jasmine, Karma, Gulp, TeamCity, LESS, Microservices / APIs, PACT, Swagger, Golang, DynamoDB, C#, SQL Server, Docker, Serverless, SNS/SQS, Lambdas, AWS DevOps.&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Immutability in JavaScript, A Contrarian View</title>
    <link>https://desalasworks.com/article/immutability-in-javascript-a-contrarian-view/</link>
    <guid>https://desalasworks.com/article/immutability-in-javascript-a-contrarian-view/</guid>
    <pubDate>Thu, 13 Apr 2017 09:57:51 GMT</pubDate><category>Code</category><category>UI</category>
    <description>&lt;p&gt;&lt;strong&gt;TL/DR:&lt;/strong&gt; Immutability is more a fashion trend than a necessity in JavaScript. If you are using React it does provide a neat work-around to some &lt;a href=&quot;https://github.com/facebook/react/issues/11527&quot; rel=&quot;nofollow&quot;&gt;confusing design choices&lt;/a&gt; in state management. However in most other situations it wont add enough value over the complexity it introduces, serving more to &lt;a href=&quot;https://dev.to/tra/expert-resum-driven-development&quot; rel=&quot;nofollow&quot;&gt;pad up a resume&lt;/a&gt; than to fulfill an actual client need.&lt;/p&gt;
&lt;p&gt;I wrote this originally as a answer to a &lt;a href=&quot;http://stackoverflow.com/questions/34385243/why-is-immutability-so-importantor-needed-in-javascript/43318963&quot;&gt;stack overflow question&lt;/a&gt; posted by someone who was as baffled by this JavaScript programming trend as I was.&lt;/p&gt;
&lt;p&gt;Here is my answer to this topic, it is contrarian and may also be contentious, but bear in mind its not the only answer, its just my own point of view.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Why is immutability so important(or needed) in javascript?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Well, I&#39;m glad you asked!&lt;/p&gt;
&lt;p&gt;Some time ago a very talented guy called &lt;a href=&quot;https://twitter.com/dan_abramov&quot; rel=&quot;nofollow&quot;&gt;Dan Abramov&lt;/a&gt; wrote a javascript state management library called &lt;a href=&quot;https://github.com/reactjs/redux&quot; rel=&quot;nofollow&quot;&gt;Redux&lt;/a&gt; which uses pure functions and immutability. He also made some &lt;a href=&quot;https://egghead.io/lessons/javascript-redux-the-single-immutable-state-tree&quot; rel=&quot;nofollow&quot;&gt;really cool videos&lt;/a&gt; that made the idea really easy to understand (and sell).&lt;/p&gt;
&lt;p&gt;The timing was perfect. The novelty of &lt;a href=&quot;https://angularjs.org/&quot; rel=&quot;nofollow&quot;&gt;Angular&lt;/a&gt; was fading, and JavaScript world was ready to fixate on the latest thing that had the right degree of cool, and this library was not only innovative but slotted in perfectly with &lt;a href=&quot;https://facebook.github.io/react/&quot; rel=&quot;nofollow&quot;&gt;React&lt;/a&gt; which was being peddled by another &lt;a href=&quot;http://facebook.com/&quot; rel=&quot;nofollow&quot;&gt;Silicon Valley powerhouse&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Sad as it may be, fashions rule in the world of JavaScript. Now Abramov is being hailed as a demigod and all us mere mortals have to subject ourselves to the &lt;a href=&quot;https://medium.com/javascript-scene/the-dao-of-immutability-9f91a70c88cd&quot; rel=&quot;nofollow&quot;&gt;Dao of Immutability&lt;/a&gt;... Wether it makes sense or not.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;What is wrong in mutating objects?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Nothing!&lt;/p&gt;
&lt;p&gt;In fact programmers have been mutating objects for er... as long as there has been objects to mutate. &lt;a href=&quot;https://en.wikipedia.org/wiki/Object-oriented_programming#History&quot; rel=&quot;nofollow&quot;&gt;50+ years&lt;/a&gt; of application development in other words.&lt;/p&gt;
&lt;p&gt;And why complicate things? When you have object &lt;code&gt;cat&lt;/code&gt; and it dies, do you really need a second &lt;code&gt;cat&lt;/code&gt; to track the change? Most people would just say &lt;code&gt;cat.isDead = true&lt;/code&gt; and be done with it.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Doesn&#39;t (mutating objects) make things simple?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;YES! .. Of course it does!&lt;/p&gt;
&lt;p&gt;Specially in JavaScript, which in practice is most useful used for rendering a view of some state that is maintained elsewhere (like in a database).&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;What if I have a new News object that has to be updated? ... How do I achieve in this case? Delete the store &amp;amp; recreate it? Isn&#39;t adding an object to the array a less expensive operation?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Well, you can go the traditional approach and update the &lt;code&gt;News&lt;/code&gt; object, so your in-memory representation of that object changes (and the view displayed to the user, or so one would hope)...&lt;/p&gt;
&lt;p&gt;Or alternatively...&lt;/p&gt;
&lt;p&gt;You can try the sexy FP/Immutability approach and add your changes to the &lt;code&gt;News&lt;/code&gt; object &lt;em&gt;to an array tracking every historical change&lt;/em&gt; so you can then iterate through the array and figure out what the correct state representation should be (phew!).&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;I am trying to learn what&#39;s right here. Please do enlighten me :)&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Fashions come and go buddy. There are many ways to skin a cat.&lt;/p&gt;
&lt;p&gt;I am sorry that you have to bear the confusion of a constantly changing set of programming paradigms. But hey, WELCOME TO THE CLUB!!&lt;/p&gt;
&lt;p&gt;Now a couple of important points to remember with regards to Immutability, and you&#39;ll get these thrown at you with the feverish intensity that only naivety can muster.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1) Immutability is awesome for avoiding &lt;a href=&quot;https://stackoverflow.com/questions/34510/what-is-a-race-condition&quot;&gt;race conditions in multi-threaded environments&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Multi-threaded environments (like C++, Java and C#) are guilty of the practice of locking objects when more than one thread wants to change them. This is bad for performance, but better than the alternative of data corruption. And yet not as good as making everything immutable (Lord praise Haskell!).&lt;/p&gt;
&lt;p&gt;BUT ALAS! In JavaScript you always &lt;a href=&quot;http://ryanmorr.com/understanding-scope-and-context-in-javascript/#execution-context&quot; rel=&quot;nofollow&quot;&gt;operate on a single thread&lt;/a&gt;. Even web workers (each runs inside a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Web_Workers_API&quot; rel=&quot;nofollow&quot;&gt;separate context&lt;/a&gt;). So since you can&#39;t have a &lt;em&gt;thread related&lt;/em&gt; race condition inside your execution context (all those lovely global variables and closures), the main point in favour of Immutability goes out the window.&lt;/p&gt;
&lt;p&gt;(Having said that, there &lt;em&gt;is&lt;/em&gt; an advantage to using pure functions in web workers, which is that you&#39;ll have no expectations about fiddling with objects on the main thread.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2) Immutability can (somehow) avoid race conditions in the state of your app.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And here is the real crux of the matter, most (React) developers will tell you that Immutability and FP can somehow work this magic that allows the state of your application to become predictable.&lt;/p&gt;
&lt;p&gt;Of course this doesn’t mean that you can avoid &lt;a href=&quot;https://softwareengineering.stackexchange.com/questions/263726/how-to-prevent-race-conditions-in-a-web-application&quot;&gt;race conditions in the database&lt;/a&gt;, to pull that one off you’d have to coordinate &lt;em&gt;all users in all browsers&lt;/em&gt;, and for that you’d need a back-end push technology like &lt;a href=&quot;https://en.wikipedia.org/wiki/WebSocket&quot; rel=&quot;nofollow&quot;&gt;WebSockets&lt;/a&gt; (more on this below) that will broadcast changes to everyone running the app.&lt;/p&gt;
&lt;p&gt;Nor does it mean that there is some inherent problem in JavaScript where your application state needs immutability in order to become predictable, any developer that has been coding front-end applications before React would tell you this.&lt;/p&gt;
&lt;p&gt;This rather confusing claim simply means that &lt;em&gt;&lt;strong&gt;if you use React your application is prone to race conditions, but that immutability allows you to take that pain away&lt;/strong&gt;&lt;/em&gt;. Why? Because React is special.. its been designed first and foremost as a &lt;a href=&quot;https://reactjs.org/docs/optimizing-performance.html&quot; rel=&quot;nofollow&quot;&gt;highly optimised rendering library&lt;/a&gt; with state management &lt;a href=&quot;https://reactjs.org/docs/react-component.html#setstate&quot; rel=&quot;nofollow&quot;&gt;subverted to that aim&lt;/a&gt;, and thus component state is managed via an &lt;a href=&quot;https://github.com/facebook/react/issues/11527&quot; rel=&quot;nofollow&quot;&gt;asynchronous chain of events&lt;/a&gt; (aka &quot;one-way data binding&quot;) that optimize rendering but you have no control over and rely on you &lt;a href=&quot;https://facebook.github.io/react/docs/state-and-lifecycle.html#using-state-correctly&quot; rel=&quot;nofollow&quot;&gt;remembering not to mutate state directly&lt;/a&gt;...&lt;/p&gt;
&lt;p&gt;Given this context, its easy to see how the need for immutability has little to do with JavaScript and a lot to do with React: if have a bunch of inter-dependent changes in your spanking new application and no easy way to figure out what your state is currently at, &lt;a href=&quot;https://reactjs.org/docs/faq-state.html#why-is-setstate-giving-me-the-wrong-value&quot; rel=&quot;nofollow&quot;&gt;you are going to get confused&lt;/a&gt;, and thus &lt;em&gt;it makes perfect sense to use immutability to track every historical change&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3) Race conditions are categorically bad.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Well, they might be if you are using React. But they are rare if you pick up a different framework.&lt;/p&gt;
&lt;p&gt;Besides, you normally have &lt;strong&gt;far bigger problems&lt;/strong&gt; to deal with… Problems like dependency hell. Like a bloated code-base. Like your CSS not getting loaded. Like a slow build process or being stuck to a monolithic back-end that makes iterating almost impossible. Like inexperienced devs not understanding whats going on and making a mess of things.&lt;/p&gt;
&lt;p&gt;You know. Reality. But hey, who cares about that?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4) Immutability makes use of &lt;a href=&quot;https://stackoverflow.com/questions/373419/whats-the-difference-between-passing-by-reference-vs-passing-by-value&quot;&gt;Reference Types&lt;/a&gt;&lt;/strong&gt; to reduce the performance impact of tracking every state change.&lt;/p&gt;
&lt;p&gt;Because seriously, if you are going to copy stuff every time your state changes, you better make sure you are smart about it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5) Immutability allows you to UNDO stuff&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Because er.. this is the number one feature your project manager is going to ask for, right?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;6) Immutable state has lots of cool potential in combination with WebSockets&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Last but not least, the accumulation of state deltas makes a pretty compelling case in combination with WebSockets, which allows for an easy consumption of &lt;a href=&quot;https://teropa.info/blog/2015/09/10/full-stack-redux-tutorial.html&quot; rel=&quot;nofollow&quot;&gt;state as a flow of immutable events&lt;/a&gt;...&lt;/p&gt;
&lt;p&gt;Once the penny drops on this concept (state being &lt;em&gt;a flow of events&lt;/em&gt; -- rather than a crude set of records representing the latest view), the immutable world becomes a magical place to inhabit. A land of &lt;a href=&quot;https://martinfowler.com/eaaDev/EventSourcing.html&quot; rel=&quot;nofollow&quot;&gt;event-sourced&lt;/a&gt; wonder and possibility that &lt;em&gt;transcends time itself&lt;/em&gt;. And when done right this can definitely make real-time apps easi&lt;em&gt;er&lt;/em&gt; to accomplish, you just broadcast the flow of events to everyone interested so they can &lt;a href=&quot;https://martinfowler.com/eaaDev/ParallelModel.html&quot; rel=&quot;nofollow&quot;&gt;build their own representation&lt;/a&gt; of the present and write back their own changes into the communal flow.&lt;/p&gt;
&lt;p&gt;But at some point you wake up and realise that all that wonder and magic &lt;a href=&quot;https://chriskiehl.com/article/event-sourcing-is-hard&quot; rel=&quot;nofollow&quot;&gt;do not come for free&lt;/a&gt;. Unlike your eager colleagues, your stakeholders (yea, the people who pay you) care little about philosophy or fashion and a lot about the money they pay to build a product they can sell. And the bottom line is that its harder to code for immutability and easier to break it, plus there is little point having an immutable front-end if you don&#39;t have a back-end to support it. When (and if!) you finally convince your stakeholders that you should publish and consume events via a &lt;a href=&quot;https://en.wikipedia.org/wiki/Push_technology&quot; rel=&quot;nofollow&quot;&gt;push techology&lt;/a&gt; like WebSockets, you find out what a &lt;a href=&quot;https://samsaffron.com/archive/2015/12/29/websockets-caution-required&quot; rel=&quot;nofollow&quot;&gt;pain it is to scale in production&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Now for some advice, should you choose to accept it.&lt;/p&gt;
&lt;p&gt;A choice to write JavaScript using FP/Immutability is also a choice to make your application code-base larger, more complex and harder to manage. I would strongly argue for limiting this approach to your Redux reducers, unless you know what you are doing... And IF you are going to go ahead and use immutability regardless, then apply &lt;a href=&quot;https://martinfowler.com/eaaDev/EventSourcing.html&quot; rel=&quot;nofollow&quot;&gt;immutable state to your whole application stack&lt;/a&gt;, and not just the client-side, as you&#39;re missing the real value of it otherwise.&lt;/p&gt;
&lt;p&gt;Now, if you are fortunate enough to be able to make choices in your work, then try and use your wisdom (or not) and &lt;a href=&quot;https://en.wikipedia.org/wiki/Golden_Rule&quot; rel=&quot;nofollow&quot;&gt;do what&#39;s right by the person who is paying you&lt;/a&gt;. You can base this on your experience, on your gut, or whats going on around you (admittedly if everyone is using React/Redux then there a valid argument that it will be easier to find a resource to continue your work).. Alternatively, you can try either &lt;a href=&quot;https://dev.to/tra/expert-resum-driven-development&quot; rel=&quot;nofollow&quot;&gt;Resume Driven Development&lt;/a&gt; or &lt;a href=&quot;https://blog.daftcode.pl/hype-driven-development-3469fc2e9b22&quot; rel=&quot;nofollow&quot;&gt;Hype Driven Development&lt;/a&gt; approaches. They might be more your sort of thing.&lt;/p&gt;
&lt;p&gt;In short, the thing to be said for immutability is that it &lt;em&gt;will&lt;/em&gt; make you fashionable with your peers, at least until the next craze comes around, by which point you&#39;ll be glad to move on.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;And &lt;a href=&quot;http://stackoverflow.com/questions/34385243/why-is-immutability-so-importantor-needed-in-javascript/43318963#link-post-43318963&quot;&gt;the reply&lt;/a&gt;!&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Hello Steven, Yes. I had all these doubts when I considered immutable.js and redux. But, your answer is amazing! It adds lot of value and thanks for addressing every single point that I had doubts on. It&#39;s so much more clear/better now even after working for months on immutable objects. – bozzmob&lt;/p&gt;&lt;/blockquote&gt;
</description>
  </item>
  <item>
    <title>How to Build a Cross-Platform Metal Detector App</title>
    <link>https://desalasworks.com/article/how-to-build-a-cross-platform-metal-detector-app-ios-android/</link>
    <guid>https://desalasworks.com/article/how-to-build-a-cross-platform-metal-detector-app-ios-android/</guid>
    <pubDate>Thu, 22 Oct 2015 07:11:35 GMT</pubDate><category>Code</category><category>Mobile</category><category>Plugins</category>
    <description>&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1818&quot; src=&quot;https://desalasworks.com/article/how-to-build-a-cross-platform-metal-detector-app-ios-android/coin-detector-xplatform-600px.jpg&quot; alt=&quot;coin-detector-xplatform-600px&quot; width=&quot;600&quot; height=&quot;375&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Did you know that your smartphone has an in-built magnetometer to power its compass?&lt;/p&gt;
&lt;p&gt;The earth&#39;s magnetic field is big but not particularly strong, and that means that the magnetometer in your phone is sensitive enough to detect small ferrous metal objects such as a coin, a large nail or a piece of cutlery which also generate small magnetic fields of their own. In other words YOU DONT HAVE TO GO AND BUY A METAL DETECTOR, you&#39;ve ALREADY GOT ONE INSIDE YOUR PHONE! We just have to unlock its potential.&lt;/p&gt;
&lt;h3&gt;Do you want to try a bit of hacking?&lt;/h3&gt;
&lt;p&gt;In this post, I&#39;m going to show you how you can build your own cross-platform metal detector app for BOTH  &lt;strong&gt;iPhone&lt;/strong&gt; and &lt;strong&gt;Android&lt;/strong&gt; phones, this app will interface with the magnetometer hardware in your phone and notify you of any ferrous metal or magnetic objects nearby.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAU9AAAAJGM3NjAxMjEyLTJmZDUtNDhkYy1iMGFmLTgwMTZhZmNhOGQ5Nw.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;366&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This should take from 30 mins to 2 hrs of your time for either platform and depending on the speed of your internet connection, perhaps longer if you have bad luck and something doesn&#39;t work straight away.&lt;/p&gt;
&lt;h2&gt;Introducing Cordova (or PhoneGap, for Adobe fans)&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://cordova.apache.org/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAU9AAAAJGE2MmIzYmRhLTE4NmYtNGY2MC1iYzZlLTNmYzEwOWEwNjA0YQ.jpg&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;286&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;http://cordova.apache.org/&quot; target=&quot;_blank&quot;&gt;Apache Cordova&lt;/a&gt; project is an open source initiative aimed at bundling a HTML page (ie `index.html` - such as the one below) into a native app that will work across just about every smartphone device. This is great news because it means that with you &lt;span class=&quot;underline&quot;&gt;only need to code your app once&lt;/span&gt; and it works on multiple devices!&lt;/p&gt;
&lt;p&gt;&lt;em&gt;# index.html&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;lt;html&amp;gt;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;My First App&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&amp;lt;body&amp;gt;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&amp;lt;button onclick=&quot;alert(&#39;World&#39;)&quot;&amp;gt;Hello&amp;lt;/button&amp;gt;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&amp;lt;/body&amp;gt;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&amp;lt;/html&amp;gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://phonegap.com/&quot; target=&quot;_blank&quot;&gt;PhoneGap&lt;/a&gt; is the same thing, but with a snazzier name trademarked by Adobe (the Photoshop people) and with an &lt;a href=&quot;http://build.phonegap.com/&quot; target=&quot;_blank&quot;&gt;online service &lt;/a&gt;that gives you a wizard-like interface for building apps so you dont have to deal with obscure command line errors, but then you have to pay Adobe for the favour.&lt;/p&gt;
&lt;h3&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAXdAAAAJDE1M2I3YjgyLWY2YjgtNDg1OS05MDZkLTkyMjM4MDYxNDc2Yg.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;350&quot; /&gt;&lt;/h3&gt;
&lt;h3&gt;So what does this &#39;Cordova&#39; thingy do for me?&lt;/h3&gt;
&lt;p&gt;Using Cordova means that you don&#39;t have to know how to setup a mobile app project because its all done for you! Cordova will basically &lt;strong&gt;generate all the folders and files&lt;/strong&gt; you need to get started with a basic HTML &#39;Hello World&#39; app for each platform.&lt;/p&gt;
&lt;p&gt;Cordova also has a powerful &#39;plugin&#39; framework that allows access to the phone&#39;s hardware, in this post we will be downloading 2 different plugins to unlock the &lt;strong&gt;Magnetometer&lt;/strong&gt; and &lt;strong&gt;Vibration&lt;/strong&gt; functionality inside your phone.&lt;/p&gt;
&lt;p&gt;To get started with a Cordova app you need to install NodeJS (&lt;a href=&quot;http://nodejs.org/&quot; target=&quot;_blank&quot;&gt;http://nodejs.org&lt;/a&gt;) which is a powerful javascript command line tool that Cordova uses to do most of the donkey-work for setting up your project.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;The Code&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Go have a look at the following &#39;&lt;strong&gt;index.html&lt;/strong&gt;&#39; file in Github, it contains all the code you need for a basic magnetometer app:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/sdesalas/cordova-magnetometer-app/blob/master/www/index.html&quot; target=&quot;_blank&quot;&gt;https://github.com/sdesalas/cordova-magnetometer-app/blob/master/www/index.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Save it to your computer:&lt;/p&gt;
&lt;p&gt;1. Right-click on &#39;&lt;strong&gt;Raw&lt;/strong&gt;&#39; button&lt;br /&gt;
2. Choose &#39;Save link as..&#39; on the context menu&lt;br /&gt;
3. Put it somewhere sensible where you can find it&lt;/p&gt;
&lt;h3&gt;Hey, this is HTML right?&lt;/h3&gt;
&lt;p&gt;Correct, that means your browser can open it.&lt;/p&gt;
&lt;p&gt;Double click to open it on a browser. You should get something like this:&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAYGAAAAJGE3MWRhNDQ5LWM2YzEtNDYzMy04Y2U2LTY2ZTEzYzNmZDkyMw.png&quot; alt=&quot;&quot; width=&quot;381&quot; height=&quot;564&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Err.. Why?&lt;/h3&gt;
&lt;p&gt;Well, your mobile has a magnetometer in it &lt;strong&gt;your PC doesn&#39;t&lt;/strong&gt;. So all you&#39;ll get out of it in a desktop browser is a ZERO reading.&lt;/p&gt;
&lt;p&gt;And thats ok, it just means everything is &lt;span class=&quot;underline&quot;&gt;working as expected&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;The Android App&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAWLAAAAJDNiMThlMDlmLWQ4MjktNGRlMC04Yjc1LTYxNzU2MzcxNDYwYQ.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;331&quot; /&gt;&lt;/p&gt;
&lt;p&gt;What You&#39;ll need:&lt;/p&gt;
&lt;p&gt;1. A PC or Mac with &lt;span class=&quot;underline&quot;&gt;NodeJS&lt;/span&gt;, Java (&lt;span class=&quot;underline&quot;&gt;JDK7&lt;/span&gt;) and &lt;span class=&quot;underline&quot;&gt;Android Studio&lt;/span&gt; installed.&lt;br /&gt;
2. An Android (4.0+) device and USB cable for testing.&lt;br /&gt;
3. Basic understanding of a command line interface (you can navigate between folders).&lt;/p&gt;
&lt;p&gt;CORPORATE FIREWALLS: Note that the steps below may not work behind a corporate firewall, you may need extra steps to set up internet access via a corporate proxy.&lt;/p&gt;
&lt;p&gt;You&#39;ve already installed &lt;a href=&quot;http://nodejs.org/&quot; target=&quot;_blank&quot;&gt;NodeJS&lt;/a&gt; right? If its a old version (older than 0.11) you might want to download the latest and re-install it.&lt;/p&gt;
&lt;p&gt;Ok, next you will need Java JDK 7 installed and Android Studio, these are needed to create a native app for Android. You can get them on the following links:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;JDK7: &lt;/strong&gt;&lt;a href=&quot;http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html&quot; target=&quot;_blank&quot;&gt;http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html&lt;/a&gt; -&amp;gt; Remember x86=32bit, x64=64bit&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Android Studio: &lt;/strong&gt;&lt;a href=&quot;https://developer.android.com/sdk/index.html&quot; target=&quot;_blank&quot;&gt;https://developer.android.com/sdk/index.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;BEWARE: after installing/running Android Studio, it will want to dowload the latest Android SDKs (the bits of functionality that enable your PC to talk to the phone hardware), this can take anywhere from 10 minutes and up to a couple of hours over a slow internet connection.&lt;/p&gt;
&lt;h3&gt;Installing Cordova&lt;/h3&gt;
&lt;p&gt;We are now going to install Cordova and create an Android project.&lt;/p&gt;
&lt;p&gt;Open up a command line window and type :&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;gt; npm install -g cordova&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAARKAAAAJDUzOWE3OGM1LTY1ZGMtNDkyZi1hMjM4LThiYzkzNzM1ZjU0Nw.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;278&quot; /&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Creating the Android Project&lt;/h3&gt;
&lt;p&gt;Next, navigate to your projects folder and create a new cordova project with android support:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;gt; cordova create magnetometer my.magnetometer magnetometer&lt;br /&gt;
&amp;gt; cd magnetometer&lt;br /&gt;
&amp;gt; cordova platform add android&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAWyAAAAJGU1ZTM5MDYzLTdiMWYtNDE1Yy05YzBmLWY2MDVmNDNiZGVhOA.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;562&quot; /&gt;If all goes well, this should have created a bunch of files and folders (ie a project structure) within your &#39;magnetometer&#39; project folder, you should be able to see them using a file explorer:&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAATpAAAAJDM3ZjMyOTlhLTdiM2QtNDBjOC04ODdhLWExZWMxODAwMTA0NA.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;383&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Copying our Metal Detector Code&lt;/h3&gt;
&lt;p&gt;The folder &#39;&lt;strong&gt;www&lt;/strong&gt;&#39; contains our web code. Here is where we&#39;ll be placing the index.html file that we &lt;a href=&quot;https://github.com/sdesalas/cordova-magnetometer-app/blob/master/www/index.html&quot; target=&quot;_blank&quot;&gt;downloaded before&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAASbAAAAJDFjYjMyZjEyLWZkZDItNDdjZS05Yzk2LWVlY2RkMmU3Y2JlOA.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;383&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Building the App&lt;/h3&gt;
&lt;p&gt;Go back to the command line and run an extra couple of commands to &#39;unlock&#39; the vibration and magnetometer functionality on your phone.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;gt; cordova plugin add cordova-plugin-vibration&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&amp;gt; cordova plugin add cordova-plugin-magnetometer&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAR-AAAAJDAxOGFiMTVlLTYxMzYtNDY1Ny04MGQ3LTE2NzkwZjdmOTM3NA.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;221&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Next we are going to &#39;build&#39; the app, so you can use it on your android phone. We need one more cordova command to &#39;prepare&#39; the app:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;gt; cordova prepare&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAPXAAAAJGMxYTE1ODBkLWQyZDMtNDg2NC05YzVlLTcxYTNlNTdiZDgyZQ.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;233&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Then follow these instructions:&lt;/p&gt;
&lt;p&gt;1. Open Android Studio&lt;br /&gt;
2. On the Welcome Prompt. Select &#39;Import Project&#39;&lt;br /&gt;
3. Click on the &#39;platforms&#92;android&#39; folder inside your project.&lt;br /&gt;
4. Press &#39;OK&#39;.&lt;br /&gt;
5. Press &#39;OK&#39; again if you get an extra prompt about Gradle settings.&lt;br /&gt;
6. Wait for the progress bar to finish.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAagAAAAJGEzMzYyNWMxLWJiYTItNDE1OC1iZTdiLTQwNzllMzFlMzY5Yw.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;486&quot; /&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAX_AAAAJGRiOTRkNDY1LTU0NTItNDk2Ny1hYjU1LTFmYjIxZWFmN2M0OA.png&quot; alt=&quot;&quot; width=&quot;440&quot; height=&quot;529&quot; /&gt;This will create an android project, next we will build the APK file that can be used to run the magnetometer app on your phone.&lt;/p&gt;
&lt;p&gt;Make sure you&#39;ve waited until all the progress bars are finished before the next steps.&lt;/p&gt;
&lt;p&gt;1. Android Studio will need to get all required Java libraries that the project depends on, this usually takes some time. Did you really wait until all progress bars and loading messages were finished?&lt;br /&gt;
2. Ok, click on the &#39;Play&#39; button at the top menu as per screen below.&lt;br /&gt;
3. This will trigger a build using Gradle. You can see the progress on the &#39;Gradle Console&#39; window.&lt;br /&gt;
4. When ready, a popup will appear asking if you want to run the emulator. &lt;strong&gt;DO NOT&lt;/strong&gt; press OK here. It will grind your computer to a halt. Just press &#39;Cancel&#39; on the popup.&lt;/p&gt;
&lt;h3&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAPPAAAAJGMxNDc0N2Q2LWMyNzQtNDZiZC1hMzlmLWZkMmRmNjAwMjRhYw.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;477&quot; /&gt;&lt;/h3&gt;
&lt;h3&gt;Installing the App on your Android Phone&lt;/h3&gt;
&lt;p&gt;Next we are going to email ourselves the completed app.&lt;/p&gt;
&lt;p&gt;1. Navigate to your &#39;magnetometer&#39; project folder using the file explorer.&lt;br /&gt;
2. Click &#39;platforms&#39; -&amp;gt; &#39;android&#39; -&amp;gt; &#39;build&#39; -&amp;gt; &#39;outputs&#39; -&amp;gt; &#39;apk&#39;&lt;br /&gt;
3. Find the file &#39;&lt;em&gt;android-debug.apk&lt;/em&gt;&#39;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAWQAAAAJDcwNzg4ZjA4LWU4ZWMtNDFlYi1hZDVmLWJmNGZkMGI5ZGZiMw.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;315&quot; /&gt;&lt;/p&gt;
&lt;p&gt;4. Next. Email it to yourself.&lt;br /&gt;
5. Go to your Android phone.&lt;br /&gt;
6. Open &#39;Settings&#39; &amp;gt; &#39;Security&#39;&lt;br /&gt;
7. Turn ON &#39;Unknown Sources&#39; (you can turn it back OFF later)&lt;br /&gt;
8. Open your email, click on the attached &#39;APK&#39; file.&lt;br /&gt;
9. You should then get an installation screen as per below.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAVJAAAAJDE3MThjYjcxLTQwOWItNGE4ZC05MGM4LTE3MjcyY2JkODA4OQ.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;533&quot; /&gt;&lt;/p&gt;
&lt;p&gt;10. Go to your Apps and look for &#39;magnetometer&#39;, then open it.&lt;br /&gt;
11. READY! Start finding some metal objects!&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAARIAAAAJGY2NmIzMTgxLTVmZWUtNDU2YS05YTVjLTliY2NiN2FlZThhOA.jpg&quot; alt=&quot;&quot; width=&quot;319&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;The iOS App&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAXVAAAAJGFiYmRkNjdkLTc1MzMtNDViZS04ODZlLWQ3ZWRmOTAzMzc5YQ.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;389&quot; /&gt;&lt;/p&gt;
&lt;p&gt;What You&#39;ll need:&lt;/p&gt;
&lt;p&gt;- A newish Mac with NodeJS and XCode installed&lt;br /&gt;
- An Apple Developer membership (US$99)&lt;br /&gt;
- An iPhone (4.0+) and USB cable for testing.&lt;br /&gt;
- Basic understanding of a command line interface (you can navigate between folders).&lt;/p&gt;
&lt;h3&gt;Installing Cordova&lt;/h3&gt;
&lt;p&gt;1. Make sure you have &lt;a href=&quot;http://nodejs.org/&quot; target=&quot;_blank&quot;&gt;NodeJS&lt;/a&gt; installed and its at a reasonably new version (0.12+).&lt;br /&gt;
2. If you need to update the version of node. Do it following &lt;a href=&quot;http://davidwalsh.name/upgrade-nodejs&quot; target=&quot;_blank&quot;&gt;this article&lt;/a&gt;.&lt;br /&gt;
3. Open a terminal window (Look for the &#39;Terminal&#39; app in Launchpad)&lt;br /&gt;
4. Type the following command to install Cordova :&lt;/p&gt;
&lt;p&gt;&lt;em&gt;$ sudo npm install -g cordova&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAASwAAAAJGY4YjMyNjYxLWJkMTktNDc4OC1hN2E0LTViMTYzMTc5NWFjZg.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;492&quot; /&gt;&lt;/p&gt;
&lt;p&gt;5. You&#39;ll be prompted to enter a password for your user account (on the mac).&lt;br /&gt;
6. There will probably be some warnings when installing Cordova (&quot;WARN&quot;), you can safely ignore these. If you get any &quot;ERROR&quot;s they are a bit more of a problem and will need attention before continuing. Type the errors into Google for help.&lt;/p&gt;
&lt;p&gt;Creating the iOS Project&lt;/p&gt;
&lt;p&gt;Once Cordova has been installed, we are going to create the project structure for our magnetometer project. Firstly, navigate to your projects folder. The commands to use are :&lt;/p&gt;
&lt;p&gt;&lt;em&gt;$ cordova create magnetometer my.magnetometer magnetometer&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;$ cd magnetometer&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;$ cordova platform add ios&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;$ cordova plugin add cordova-plugin-vibration&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;$ cordova plugin add cordova-plugin-magnetometer&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAa3AAAAJDM3NDBiMTFmLWUwNTYtNGQwNS05YWU1LTg4Yjc0Y2VlMGM1NQ.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;529&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Copying our Metal Detector App Code&lt;/h3&gt;
&lt;p&gt;This should have created your project structure as per following screenshot. Make sure you delete the contents of the &#39;www&#39; folder and replace them with the &#39;index.html&#39; file you &lt;a href=&quot;https://github.com/sdesalas/cordova-magnetometer-app/blob/master/www/index.html&quot; target=&quot;_blank&quot;&gt;downloaded earlier&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAaiAAAAJDlkNDIyYzgyLTliMDItNDFhMC1hNjk4LWRjOGZkMDk3NzdiNQ.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;318&quot; /&gt;You will then need to run the following command on your &#39;magnetometer&#39; folder to &#39;prepare&#39; the files (it will copy the &#39;index.html&#39; to the XCode build folder).&lt;/p&gt;
&lt;p&gt;&lt;em&gt;$ cordova prepare&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAQ9AAAAJDRmZmJiZThmLWQ2M2ItNGY5Ni1hMWE3LWQyOWMzNzIyOTFhNA.png&quot; alt=&quot;&quot; width=&quot;619&quot; height=&quot;298&quot; /&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Building the iOS App&lt;/h3&gt;
&lt;p&gt;And now we can continue to XCode by finding the file &#39;magnetometer.xcodeproj&#39; inside our project folder (look inside the sub-folder &#39;platforms&#39; and &#39;ios&#39;). Just double-click on it and it will open (if you have XCode installed).&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAb2AAAAJGNkZDIzOTI1LWY5YjMtNDU5YS04NzlmLWFiZmE5M2MzY2JiMQ.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;395&quot; /&gt;&lt;/em&gt;Make sure you are signed in as an apple developer. Joining costs US$99. You cannot drop an app on your iOS device without one of these:&lt;/p&gt;
&lt;p&gt;1. Go to &#39;XCode&#39; (on the top menu)&lt;br /&gt;
2. Select &#39;Preferences...&#39;, then &#39;Accounts&#39;&lt;br /&gt;
3. Click the plus (+) sign to add an account&lt;br /&gt;
4. Enter your Apple Developer email and password&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAQ1AAAAJDAxMzdjNzUwLTU1MzgtNDA0Yi05MjI4LTUwZTI3MTBkMDk3Nw.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;492&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Running the App on your iPhone&lt;/h3&gt;
&lt;p&gt;Then just go and run the app! This bit is even simpler than for Android!&lt;/p&gt;
&lt;p&gt;1. Connect your iPhone to your Mac using the USB cable.&lt;br /&gt;
2. Select your iPhone as the device &#39;target&#39; on the top menu&lt;br /&gt;
3. Press the &#39;Play&#39; button to run the build.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAceAAAAJDEwNDVkM2Y3LTQ5MDktNDE5Yi04NTBlLWI1OTM1NzBiYjljYw.png&quot; alt=&quot;&quot; width=&quot;640&quot; height=&quot;433&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And VOILA! Now start finding some metal with your iPhone!&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAa3AAAAJDNjOTZkZDAwLTIzZTctNDA1Ny05MzcxLWFjYmFmMzkzYjg1Yg.jpg&quot; alt=&quot;&quot; width=&quot;400&quot; height=&quot;400&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;And thats IT!&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;That concludes my post for today, thanks for taking an interest. I hope you didn&#39;t have to bang your head against the keyboard too much to get this working.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;center&quot; src=&quot;https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAARHAAAAJGFiOTcxZTkyLWFiMzctNGZmNi04ZjgxLTljNGE3NmZkYmVjOA.jpg&quot; alt=&quot;&quot; width=&quot;570&quot; height=&quot;381&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Please feel free to write your comments and experiences below.&lt;/p&gt;
&lt;p&gt;If you liked it then you are welcome to shout me a beer or help me out by sharing it with your friends and colleagues.&lt;/p&gt;
&lt;p&gt;BYE!!!&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Tasmanian Convict Finder</title>
    <link>https://desalasworks.com/tasmanian-convict-finder/</link>
    <guid>https://desalasworks.com/tasmanian-convict-finder/</guid>
    <pubDate>Sat, 12 Sep 2015 07:37:45 GMT</pubDate><category>Mobile</category>
    <description>&lt;p&gt;Browse and search through detailed records of 85,000 convicts transported to Tasmania and those convicted locally through the convict system (1803-1893).&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=info.tasmanianconvictfinder&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-large wp-image-1795&quot; src=&quot;https://desalasworks.com/tasmanian-convict-finder/tasmanian-convict-finder-600x400.jpg&quot; alt=&quot;tasmanian-convict-finder&quot; width=&quot;600&quot; height=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This app uses publicly available data from &lt;a href=&quot;https://data.gov.au/dataset/tasmanian-convicts-1803-1893&quot; target=&quot;_blank&quot;&gt;data.gov.au&lt;/a&gt; provided by LINC and the Department of Education in Tasmania, as well as newspaper articles sourced from the National Library of Australia.&lt;/p&gt;
&lt;p&gt;It is cross-platform and available in both iPhone and Android version.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=info.tasmanianconvictfinder&amp;amp;hl=en&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-1808 noborder&quot; src=&quot;https://desalasworks.com/tasmanian-convict-finder/google-play-en@2x-300x106.png&quot; alt=&quot;google-play-en@2x&quot; width=&quot;300&quot; height=&quot;106&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://itunes.apple.com/us/app/tasmanian-convict-finder/id1024005717?mt=8&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-1806 noborder&quot; src=&quot;https://desalasworks.com/tasmanian-convict-finder/apple-app-store-icon-300x103.png&quot; alt=&quot;apple-app-store-icon&quot; width=&quot;300&quot; height=&quot;103&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Research your Ancestry&lt;/h2&gt;
&lt;p&gt;The app provides a useful reference for anyone seeking to find out more about the convict history of this beautiful island in Australia, and is a handy pocket guide for people researching their ancestry.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-large wp-image-1755&quot; src=&quot;https://desalasworks.com/tasmanian-convict-finder/tasmanian-convict-finder.workflow-600x356.png&quot; alt=&quot;tasmanian-convict-finder.workflow&quot; width=&quot;600&quot; height=&quot;356&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Initially built as an entry into Govhack 2015, this app was completed though unfortunately not in time to join the prize lists.&lt;/p&gt;
</description>
  </item>
  <item>
    <title>TrifleJS</title>
    <link>https://desalasworks.com/triflejs/</link>
    <guid>https://desalasworks.com/triflejs/</guid>
    <pubDate>Sat, 12 Sep 2015 07:19:25 GMT</pubDate><category>Code</category><category>UI</category><category>Libraries</category>
    <description>&lt;p&gt;&lt;a href=&quot;http://triflejs.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;img class=&quot;alignnone wp-image-1741 size-full&quot; src=&quot;https://desalasworks.com/triflejs/triflejs-org.png&quot; alt=&quot;triflejs-org&quot; width=&quot;600&quot; height=&quot;1234&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Environmental Defenders Office</title>
    <link>https://desalasworks.com/environmental-defenders-office/</link>
    <guid>https://desalasworks.com/environmental-defenders-office/</guid>
    <pubDate>Mon, 25 Nov 2013 02:30:13 GMT</pubDate><category>Websites</category>
    <description>&lt;p&gt;This project was a custom Wordpress Template build for the Tasmanian &lt;a href=&quot;https://www.facebook.com/pages/EDO-Tasmania-Environmental-Defenders-Office-Tasmania/713857485292000&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Environmental Defenders Office&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.edotas.org.au/&quot;&gt;&lt;img class=&quot;alignnone wp-image-1698 size-full&quot; src=&quot;https://desalasworks.com/environmental-defenders-office/edo_tas_desktop_screen.jpg&quot; alt=&quot;edo_tas_desktop_screen&quot; width=&quot;600&quot; height=&quot;510&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The project included responsive support for Tablet and Mobile devices at various resolutions:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://desalasworks.com/environmental-defenders-office/edo_tasmania_devices.jpg&quot;&gt;&lt;img class=&quot;alignnone size-large wp-image-1699&quot; src=&quot;https://desalasworks.com/environmental-defenders-office/edo_tasmania_devices-600x350.jpg&quot; alt=&quot;edo_tasmania_devices&quot; width=&quot;600&quot; height=&quot;350&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The website went live in late November 2013, just in time to help the Environmental Defenders Office establish its online presence before the government &lt;a href=&quot;http://www.abc.net.au/news/2013-12-18/funding-cut-to-environmental-defenders-offices/5164934&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;removed funding for the EDO network&lt;/a&gt;.&lt;/p&gt;
</description>
  </item>
  <item>
    <title>AutoTrader UK</title>
    <link>https://desalasworks.com/autotrader-uk/</link>
    <guid>https://desalasworks.com/autotrader-uk/</guid>
    <pubDate>Fri, 15 Nov 2013 06:51:45 GMT</pubDate><category>Code</category><category>UI</category><category>Websites</category>
    <description>&lt;p&gt;This was a role working on Interface Development for Trader Media&#39;s online marketplace with over 1 billion page impressions per month.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-large wp-image-1724&quot; src=&quot;https://desalasworks.com/autotrader-uk/autotrader_main-600x520.jpg&quot; alt=&quot;autotrader_main&quot; width=&quot;600&quot; height=&quot;520&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I mainly focused on creating rich interfaces and user journeys with Event-driven and Object-Oriented JavaScript, DOM, HTML5, jQuery, AJAX, JSON and Backbone.js MVC framework continuously tested with Jasmine/Rhino.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-large wp-image-1726&quot; src=&quot;https://desalasworks.com/autotrader-uk/autotrader_gallery-600x369.jpg&quot; alt=&quot;autotrader_gallery&quot; width=&quot;600&quot; height=&quot;369&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Our team used Agile development approach with Continuous Integration (CI), pair-programming and short development cycles based on Thoughtworks Extreme Programming (XP) model for Java/JUnit TDD projects.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-large wp-image-1725&quot; src=&quot;https://desalasworks.com/autotrader-uk/autotrader_agile_dave-600x360.jpg&quot; alt=&quot;autotrader_agile_dave&quot; width=&quot;600&quot; height=&quot;360&quot; /&gt;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>XXXX Island Competition</title>
    <link>https://desalasworks.com/xxxx-island-competition/</link>
    <guid>https://desalasworks.com/xxxx-island-competition/</guid>
    <pubDate>Sun, 10 Mar 2013 08:04:26 GMT</pubDate><category>Competitions</category><category>Websites</category>
    <description>&lt;p&gt;The XXXX Island competition was a Facebook Competition run by &lt;a href=&quot;https://www.facebook.com/danmurphys&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Dan Murphy&#39;s&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This was produced in conjunction with &lt;a href=&quot;http://redjelly.com.au/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;RedJelly&lt;/a&gt;, an advertising agency based in Tasmania.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://desalasworks.com/xxxx-island-competition/dm_island_competition_desktop.jpg&quot;&gt;&lt;img class=&quot;alignnone size-large wp-image-1681&quot; src=&quot;https://desalasworks.com/xxxx-island-competition/dm_island_competition_desktop-600x390.jpg&quot; alt=&quot;dm_island_competition_desktop&quot; width=&quot;600&quot; height=&quot;390&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The competition had to be available on both Desktop and Mobile formats.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://desalasworks.com/xxxx-island-competition/dm_island_competition_mobile.jpg&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1682&quot; src=&quot;https://desalasworks.com/xxxx-island-competition/dm_island_competition_mobile.jpg&quot; alt=&quot;dm_island_competition_mobile&quot; width=&quot;600&quot; height=&quot;471&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;National Advertising: Dealing with High Volumes&lt;/h3&gt;
&lt;p&gt;Due to the high volume of competition entrants the competition was hosted with &lt;a href=&quot;http://heroku.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Heroku&lt;/a&gt;, which allowed provisioning of additional servers to handle surges in traffic following advertising.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://heroku.com/&quot;&gt;&lt;img class=&quot;alignnone wp-image-1693 size-full&quot; src=&quot;https://desalasworks.com/xxxx-island-competition/dm_island_competition_heroku.jpg&quot; alt=&quot;dm_island_competition_heroku&quot; width=&quot;600&quot; height=&quot;413&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The competition was highly successful, receiving more than 10,000 entries.&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Dan Murphys Lucky 8</title>
    <link>https://desalasworks.com/dan-murphys-lucky-8/</link>
    <guid>https://desalasworks.com/dan-murphys-lucky-8/</guid>
    <pubDate>Mon, 25 Feb 2013 00:40:16 GMT</pubDate><category>UI</category><category>Websites</category><category>Competitions</category>
    <description>&lt;p&gt;This Facebook competition was run on Chinese New Year 2013, it was designed by &lt;a href=&quot;http://redjelly.com.au/&quot; target=&quot;_blank&quot;&gt;RedJelly&lt;/a&gt; and hosted by me using &lt;a href=&quot;http://heroku.com/&quot; target=&quot;_blank&quot;&gt;Heroku&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone wp-image-1688 size-full&quot; src=&quot;https://desalasworks.com/dan-murphys-lucky-8/dm_lucky_8_desktop.jpg&quot; alt=&quot;dm_lucky_8_desktop&quot; width=&quot;600&quot; height=&quot;419&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The competition uses the entrant&#39;s date of birth to show their Chinese horoscope before entering the competition:&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone wp-image-1689 size-full&quot; src=&quot;https://desalasworks.com/dan-murphys-lucky-8/dm_lucky_8_desktop_dragon.jpg&quot; alt=&quot;dm_lucky_8_desktop_dragon&quot; width=&quot;600&quot; height=&quot;419&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It included access to the Facebook API for authentication and to obtain email and date of birth information from competition entrants.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone wp-image-1686 size-full&quot; src=&quot;https://desalasworks.com/dan-murphys-lucky-8/dm_lucky_eight_dashboard.png&quot; alt=&quot;dm_lucky_eight_dashboard&quot; width=&quot;600&quot; height=&quot;419&quot; /&gt;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>MBTA mTicket</title>
    <link>https://desalasworks.com/mbta-mticket/</link>
    <guid>https://desalasworks.com/mbta-mticket/</guid>
    <pubDate>Fri, 13 Jul 2012 13:38:36 GMT</pubDate><category>Mobile</category><category>UI</category><category>Startups</category>
    <description>&lt;p&gt;&lt;em&gt;A 6 month cross-platform (iOS and Android) mobile app project for Masabi, a specialist mTicketing company based near London Bridge. The MBTA mTicket application was launched in the Android and iPhone app markets in November 2012, and was a complete success grossing $1 million of sold tickets in the Boston Rail network for the first ten weeks of operation.&lt;/em&gt;&lt;/p&gt;
&lt;figure class=&quot;wp-caption alignnone&quot; style=&quot;max-width:600px&quot;&gt;&lt;a title=&quot;MBTA mTicket in the Google Play Store&quot; href=&quot;https://play.google.com/store/apps/details?id=com.mbta.mobileapp&amp;amp;hl=en&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;&lt;img class=&quot;size-full wp-image-1526&quot; title=&quot;MBTA mTicket in the Google Play store.&quot; src=&quot;https://desalasworks.com/mbta-mticket/mbta.mticket.1.jpg&quot; alt=&quot;MBTA mTicket in the Google Play store.&quot; width=&quot;600&quot; height=&quot;293&quot; /&gt;&lt;/a&gt;&lt;figcaption class=&quot;wp-caption-text&quot;&gt;MBTA mTicket in the Google Play store.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2&gt;Developing the Front End User Experience&lt;/h2&gt;
&lt;p&gt;The project focused on building the User Interface for the application, this was done as a HTML5 /JavaScript UI due to the inherent advantages in being able to share code across different platforms. During development, we regularly tested against Android, iOS, BlackBerry, Symbian WebOS and Windows Mobile.&lt;/p&gt;
&lt;p&gt;&lt;iframe src=&quot;https://www.youtube.com/embed/C1l5MxnHR3c?feature=player_detailpage&quot; width=&quot;600&quot; height=&quot;340&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;h2&gt;MBTA mTicket Payment Walkthrough&lt;/h2&gt;
&lt;p&gt;The process for purchasing tickets is straight forward, no complicated steps or black magic.&lt;/p&gt;
&lt;p&gt;To purchase a round trip ticket to/from Boston the steps are:&lt;/p&gt;
&lt;p&gt;1) Click &#39;Buy Tickets&#39;&lt;br /&gt;
2) Choose a &#39;From&#39; and &#39;To&#39; Station from the list.&lt;br /&gt;
3) Choose a &#39;Round Trip&#39; ticket&lt;br /&gt;
4) Choose an existing card (the app stores a payment key after the first time).&lt;br /&gt;
5) Enter the Card CVV&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1647&quot; src=&quot;https://desalasworks.com/mbta-mticket/mbta.workflow.new1_.png&quot; alt=&quot;mbta.workflow.new1&quot; width=&quot;600&quot; height=&quot;353&quot; /&gt;&lt;/p&gt;
&lt;p&gt;6) Review your purchase&lt;br /&gt;
7) Press &#39;Pay Now&#39;&lt;br /&gt;
8) DONE!&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1649&quot; src=&quot;https://desalasworks.com/mbta-mticket/mbta.workflow.new2_.png&quot; alt=&quot;mbta.workflow.new2&quot; width=&quot;600&quot; height=&quot;354&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Once the transaction goes through, the ticket is loaded into the My Tickets section. You now have two round trips to Boston waiting for you.&lt;/p&gt;
&lt;p&gt;These last few panels are a shot of your ticket. The rectangle at the top shows the current time, the time block moves back and forth, and the three blocks are multi-colored. The color scheme changes on a daily basis according to a scheme that the conductor knows. Once the ticket is used it changes into a grey scheme. The conductor when he approaches will generally glance at the screen, nod with a &quot;thanks&quot; and put a paper slip in the holder above your head. Done.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1650&quot; src=&quot;https://desalasworks.com/mbta-mticket/mbta.workflow.new3_.png&quot; alt=&quot;mbta.workflow.new3&quot; width=&quot;600&quot; height=&quot;354&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;MBTA mTicket in the News&lt;/h2&gt;
&lt;p&gt;These are some of the online articles that were published before and after launch:&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1539&quot; style=&quot;border: 0;&quot; title=&quot;logo.engadget&quot; src=&quot;https://desalasworks.com/mbta-mticket/logo.engadget.png&quot; alt=&quot;&quot; width=&quot;171&quot; height=&quot;60&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Apr 23rd, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.engadget.com/2012/04/23/mbta-masabi-smartphone-ticketing/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;MBTA and Masabi team up for first smartphone rail ticketing system in the US, launching in Boston this fall&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Jul 12th, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.engadget.com/2012/07/12/new-york-mta-announces-smartphone-ticketing-trials/&quot;&gt;New York MTA announces smartphone-based ticketing trials aboard Metro-North Railroad&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img class=&quot;alignnone&quot; style=&quot;border: 0;&quot; src=&quot;https://s.wsj.net/img/logo_black_sm.png&quot; alt=&quot;&quot; width=&quot;194&quot; height=&quot;18&quot; /&gt;&lt;/p&gt;
&lt;p&gt;July 11, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://blogs.wsj.com/metropolis/2012/07/11/new-smartphone-app-could-replace-railroad-tickets/?mod=google_news_blog&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;New Smartphone App Could Replace Railroad Tickets&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1544&quot; style=&quot;border: 0;&quot; title=&quot;logo.reuters&quot; src=&quot;https://desalasworks.com/mbta-mticket/logo.reuters.png&quot; alt=&quot;&quot; width=&quot;200&quot; height=&quot;56&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Nov 12, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.reuters.com/article/2012/11/12/idUS110891+12-Nov-2012+BW20121112&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;MBTA &amp;amp; Masabi Launch US` First Smartphone Commuter Rail Ticketing System&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Jul 11, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.reuters.com/article/2012/07/11/usa-train-digital-idUSL2E8IB7Y920120711&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Digital train tickets to replace paper for some NY commuters&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1545&quot; style=&quot;border: 0;&quot; title=&quot;logo.metro.us&quot; src=&quot;https://desalasworks.com/mbta-mticket/logo.metro_.us_.png&quot; alt=&quot;&quot; width=&quot;170&quot; height=&quot;91&quot; /&gt;&lt;/p&gt;
&lt;p&gt;November 27, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.metro.us/boston/boston/article/1156976--mticket-mbta-releases-mobile-ticketing-app-at-south-station&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;mTicket: MBTA releases mobile ticketing app at South Station&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;December 04, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.metro.us/boston/boston/article/1157483--mticket-t-reports-225-000-in-mobile-app-ticket-sales-since-november-launch&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;mTicket: T reports $225,000 in mobile app ticket sales since November launch&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;January 15, 2013&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.metro.us/boston/local/article/1159852--mticket-sees-1-million-in-commuter-line-sales&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;mTicket sees $1 million in commuter line sales&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1546&quot; style=&quot;border: 0;&quot; title=&quot;logo.bostino&quot; src=&quot;https://desalasworks.com/mbta-mticket/logo.bostino.png&quot; alt=&quot;&quot; width=&quot;200&quot; height=&quot;60&quot; /&gt;&lt;/p&gt;
&lt;p&gt;November 21st, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://bostinno.com/channels/what-bostonians-are-thankful-for/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;What Bostonians Are Thankful For&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;November 27th, 2012&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://bostinno.com/2012/11/27/mobile-ticketing-coming-to-mbta-commuter-boats-trains-riders-can-purchase-monthly-passes/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Mobile Ticketing Coming to MBTA Boats &amp;amp; More Commuter Trains, Riders Can Purchase Monthly Passes&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Customer Respose&lt;/h2&gt;
&lt;p&gt;The MBTA mTicketing app went on to become a huge success shortly after launch. Customers reported a &#39;seamless experience&#39; with &#39;great usability&#39;, &#39;very convenient&#39;, &#39;neat &amp;amp; efficient&#39; etc.&lt;/p&gt;
&lt;p&gt;These are some of the responses the MBTA customers tweeted shortly after launch:&lt;/p&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;Just bought my first mobile &lt;a href=&quot;https://twitter.com/search/%23mbcr&quot;&gt;#mbcr&lt;/a&gt; ticket with the new &lt;a href=&quot;https://twitter.com/search/%23mbta&quot;&gt;#mbta&lt;/a&gt; mTicket app. Super easy, great interface. Will def. make life easier &lt;img class=&quot;wp-smiley&quot; src=&quot;https://www.masabi.com/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; /&gt; @&lt;a href=&quot;https://twitter.com/mbtagm&quot;&gt;mbtagm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— Beth Vitale (@vitale_beth) &lt;a href=&quot;https://twitter.com/vitale_beth/status/267982770431721473&quot; data-datetime=&quot;2012-11-12T13:30:46+00:00&quot;&gt;November 12, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;I absolutely love the new &lt;a href=&quot;https://twitter.com/search/%23mbta&quot;&gt;#mbta&lt;/a&gt; commuter rail app. It’s so convenient and easy. &lt;a href=&quot;https://twitter.com/search/%23greatjob&quot;&gt;#greatjob&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— Colin Loiselle™ (@colinloiselle) &lt;a href=&quot;https://twitter.com/colinloiselle/status/268137471211081728&quot; data-datetime=&quot;2012-11-12T23:45:29+00:00&quot;&gt;November 12, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;Whoever created this MBTA app is an actual angel from heaven&lt;/p&gt;
&lt;p&gt;— connor (@connorlately) &lt;a href=&quot;https://twitter.com/connorlately/status/268449503508578304&quot; data-datetime=&quot;2012-11-13T20:25:23+00:00&quot;&gt;November 13, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;.Just used the &lt;a href=&quot;https://twitter.com/search/%23MBTA&quot;&gt;#MBTA&lt;/a&gt; mTicket app on my &lt;a href=&quot;https://twitter.com/search/%23Android&quot;&gt;#Android&lt;/a&gt; phone. Pretty neat &amp;amp; efficient! &lt;a href=&quot;https://twitter.com/search/%23ilovetechnology&quot;&gt;#ilovetechnology&lt;/a&gt; cc: @&lt;a href=&quot;https://twitter.com/mbtagm&quot;&gt;mbtagm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— Meg McDevitt (@OhThatMeg) &lt;a href=&quot;https://twitter.com/OhThatMeg/status/268846898830524416&quot; data-datetime=&quot;2012-11-14T22:44:30+00:00&quot;&gt;November 14, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;MBTA’s making mobile e-tickets for the Commuter Rail now?! No more waiting in line and missing the train! WOO&lt;/p&gt;
&lt;p&gt;— Timmy C (@_LeTimmy) &lt;a href=&quot;https://twitter.com/_LeTimmy/status/268493698109669376&quot; data-datetime=&quot;2012-11-13T23:21:00+00:00&quot;&gt;November 13, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;Transforming &lt;a href=&quot;https://twitter.com/search/%23transit&quot;&gt;#transit&lt;/a&gt; @&lt;a href=&quot;https://twitter.com/masabi_com&quot;&gt;masabi_com&lt;/a&gt;RT @&lt;a href=&quot;https://twitter.com/bostonglobe&quot;&gt;bostonglobe&lt;/a&gt;: The MBTA says its smartphone ticket app for commuters is a hit &lt;a title=&quot;http://b.globe.com/RDCmot&quot; href=&quot;http://t.co/6CSqOiT1&quot;&gt;b.globe.com/RDCmot&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— Elizabeth Towler (@LizTowler) &lt;a href=&quot;https://twitter.com/LizTowler/status/269035129404538880&quot; data-datetime=&quot;2012-11-15T11:12:27+00:00&quot;&gt;November 15, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot; data-in-reply-to=&quot;270502171441774594&quot;&gt;&lt;p&gt;@&lt;a href=&quot;https://twitter.com/mbtagm&quot;&gt;mbtagm&lt;/a&gt; downloaded the &lt;a href=&quot;https://twitter.com/search/%23MBTA&quot;&gt;#MBTA&lt;/a&gt; mTicket App today. real cutting edge!&lt;/p&gt;
&lt;p&gt;— eileensideways (@eileensideways) &lt;a href=&quot;https://twitter.com/eileensideways/status/270512160864600064&quot; data-datetime=&quot;2012-11-19T13:01:39+00:00&quot;&gt;November 19, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;This app just made my life so much easier. &lt;a title=&quot;https://play.google.com/store/apps/details?id=com.mbta.mobileapp&quot; href=&quot;https://t.co/sKqSdEyM&quot;&gt;play.google.com/store/apps/det…&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— Patrick Rodriguez (@LightAesthetic) &lt;a href=&quot;https://twitter.com/LightAesthetic/status/270222307782438912&quot; data-datetime=&quot;2012-11-18T17:49:53+00:00&quot;&gt;November 18, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;.@&lt;a href=&quot;https://twitter.com/mbtagm&quot;&gt;mbtagm&lt;/a&gt; the new commuter rail ticketing app is amazing. I love it. &lt;a href=&quot;https://twitter.com/search/%23mbta&quot;&gt;#mbta&lt;/a&gt; &lt;a href=&quot;https://twitter.com/search/%23boston&quot;&gt;#boston&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— cool dr money (@xieish) &lt;a href=&quot;https://twitter.com/xieish/status/269963107290468352&quot; data-datetime=&quot;2012-11-18T00:39:55+00:00&quot;&gt;November 18, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;@&lt;a href=&quot;https://twitter.com/mbtanow&quot;&gt;mbtanow&lt;/a&gt; Love the new MBTA Ticketing App!&lt;/p&gt;
&lt;p&gt;— Owen (@OFenwick) &lt;a href=&quot;https://twitter.com/OFenwick/status/269789521296642050&quot; data-datetime=&quot;2012-11-17T13:10:08+00:00&quot;&gt;November 17, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;Mbta app is dope&lt;/p&gt;
&lt;p&gt;— John M. Billert (@_billert) &lt;a href=&quot;https://twitter.com/_billert/status/269568254522044417&quot; data-datetime=&quot;2012-11-16T22:30:54+00:00&quot;&gt;November 16, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p&gt;Been using &lt;a href=&quot;https://twitter.com/search/%23MBTA&quot;&gt;#MBTA&lt;/a&gt; app this week on the commuter rail – so far, so good! Very convenient. @&lt;a href=&quot;https://twitter.com/mbtagm&quot;&gt;mbtagm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;— Ashley (@accordingtoalg) &lt;a href=&quot;https://twitter.com/accordingtoalg/status/269427615453028352&quot; data-datetime=&quot;2012-11-16T13:12:03+00:00&quot;&gt;November 16, 2012&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;script src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Markit Commission Manager</title>
    <link>https://desalasworks.com/markit-commission-manager/</link>
    <guid>https://desalasworks.com/markit-commission-manager/</guid>
    <pubDate>Wed, 04 Apr 2012 21:54:20 GMT</pubDate><category>Web Applications</category>
    <description>&lt;p&gt;&lt;em&gt;Commission Manager is a trade reconciliation tool enabling brokers and funds in the worlds largest financial institutions to settle their commission differences.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;The Project&lt;/h2&gt;
&lt;p&gt;The project involved a standardized platform to aggregate and manage trade information, commission balances and vendor invoices and payments.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.markit.com/en/products/distribution/research-manager/commission-manager.page?&quot;&gt;&lt;img class=&quot;size-large wp-image-1317&quot; title=&quot;CommissionManager Dashboard&quot; src=&quot;https://desalasworks.com/markit-commission-manager/CommissionManager_Dashboard_Full-600x388.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;388&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Functionality&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://www.markit.com/en/products/distribution/research-manager/commission-manager.page?#&quot;&gt;Markit Commission Manager&lt;/a&gt; enables users to reconcile their trading commissions with multiple counterparties and then instruct those counterparties to pay for research and brokerage services – all from a single platform. This efficient workflow eases the administrative burden of managing multiple commission arrangements.&lt;/p&gt;
&lt;p&gt;The functionality is centered around trade reconciliation, raising of invoices and managing balance differences.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Detailed reporting of balance, trade and invoice information&lt;/li&gt;
&lt;li&gt;Efficient tools to manage and highlight trade breaks&lt;/li&gt;
&lt;li&gt;Administrative configurations for new users, tolerance levels, and arrangements&lt;/li&gt;
&lt;li&gt;Compliance tracking of interactions within the Commission Manager system&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Business Partner Integration&lt;/h2&gt;
&lt;p&gt;In addition, it was necessary to provide systems integration with all broker-dealers that were involved in the project.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.barcap.com/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1345&quot; title=&quot;Barclays_Capital-1&quot; src=&quot;https://desalasworks.com/markit-commission-manager/Barclays_Capital-1.gif&quot; alt=&quot;&quot; width=&quot;145&quot; height=&quot;145&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://www.credit-suisse.com/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1346&quot; title=&quot;credit-suisse&quot; src=&quot;https://desalasworks.com/markit-commission-manager/credit-suisse.jpg&quot; alt=&quot;&quot; width=&quot;145&quot; height=&quot;145&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://www.jpmorgan.com/&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1437&quot; title=&quot;jp_logo&quot; src=&quot;https://desalasworks.com/markit-commission-manager/jp_logo.png&quot; alt=&quot;&quot; width=&quot;145&quot; height=&quot;145&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://www.gs.com/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1348&quot; title=&quot;goldman-sachs&quot; src=&quot;https://desalasworks.com/markit-commission-manager/goldman-sachs.gif&quot; alt=&quot;&quot; width=&quot;145&quot; height=&quot;145&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://www.ml.com/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1351&quot; title=&quot;merril-lynch&quot; src=&quot;https://desalasworks.com/markit-commission-manager/merril-lynch.jpg&quot; alt=&quot;&quot; width=&quot;145&quot; height=&quot;145&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://www.ubs.com/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1353&quot; title=&quot;UBS-Logo&quot; src=&quot;https://desalasworks.com/markit-commission-manager/UBS-Logo.png&quot; alt=&quot;&quot; width=&quot;145&quot; height=&quot;145&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://www.db.com/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1355&quot; title=&quot;deutsche bank logo&quot; src=&quot;https://desalasworks.com/markit-commission-manager/deutsche_bank_logo.png&quot; alt=&quot;&quot; width=&quot;145&quot; height=&quot;145&quot; /&gt;&lt;/a&gt; &lt;a href=&quot;http://www.citibank.com/&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-1440&quot; title=&quot;citi_logo&quot; src=&quot;https://desalasworks.com/markit-commission-manager/citi_logo.png&quot; alt=&quot;&quot; width=&quot;145&quot; height=&quot;145&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Comments on the Commission Manager platform&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;&lt;img class=&quot;size-full wp-image-390 alignleft&quot; style=&quot;float: left; margin-right: 20px; border: 0px;&quot; title=&quot;User&quot; src=&quot;https://desalasworks.com/markit-commission-manager/user-female.gif&quot; alt=&quot;User&quot; width=&quot;60&quot; height=&quot;80&quot; /&gt;Sofia Rossato&lt;/strong&gt; - Head of Markit Research Manager at Markit&lt;/p&gt;
&lt;div style=&quot;float: left; max-width: 500px;&quot;&gt;Markit Commission Manager is the latest addition to our Markit Research Manager range of services. Our objective is to enable investment firms to manage their entire research workflow - including sourcing research, tracking corporate access, voting on brokers and managing research commissions - from one single platform to bring greater efficiency and internal visibility to the whole process. Markit Commission Manager is the final piece in the jigsaw. We have partnered closely with BofA Merrill Lynch, Barclays Capital, Citi, Credit Suisse, Deutsche Bank, Goldman Sachs, J.P. Morgan and Morgan Stanley to ensure the platform meets the needs of the industry.&lt;/div&gt;
&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;&lt;img class=&quot;size-full wp-image-389 alignleft&quot; style=&quot;float: left; margin-right: 20px; border: 0px;&quot; title=&quot;User&quot; src=&quot;https://desalasworks.com/markit-commission-manager/user-male.gif&quot; alt=&quot;User&quot; width=&quot;60&quot; height=&quot;80&quot; /&gt;Frank Volino &lt;/strong&gt; - Head of Global Commission Management Services at Citi&lt;/p&gt;
&lt;div style=&quot;float: left; max-width: 500px;&quot;&gt;This platform is good news for buy-side and sell-side alike. It will allow the buy-side to use a standardised set of tools to manage their commission credits at multiple broker-dealers. We are very pleased to be part of this important industry initiative. This platform is in a strong position to become the industry standard.&lt;/div&gt;
&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;
&lt;h2&gt;Commission Manager in the News&lt;/h2&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.bankingtech.com/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot; wp-image-1320 alignnone&quot; style=&quot;border: 0;&quot; title=&quot;Banking Technology&quot; src=&quot;https://desalasworks.com/markit-commission-manager/bt_logo_main.gif&quot; alt=&quot;&quot; width=&quot;135&quot; height=&quot;63&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;font-size: 85%; line-height: 1.4em;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;07 Oct 2011&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;Markit launches commission management platform&lt;/strong&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.bankingtech.com/bankingtech/article.do?articleid=20000213861&quot; target=&quot;_blank&quot;&gt;http://www.bankingtech.com/bankingtech/article.do?articleid=20000213861&lt;/a&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;a href=&quot;http://www.securitiestechnologymonitor.com/&quot; target=&quot;_blank&quot;&gt;&lt;img class=&quot;wp-image-1322 alignleft&quot; style=&quot;border: 0;&quot; title=&quot;Securities Technology Monitor&quot; src=&quot;https://desalasworks.com/markit-commission-manager/sin_header_new.gif&quot; alt=&quot;&quot; width=&quot;137&quot; height=&quot;74&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;font-size: 85%; line-height: 1.4em;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;04 Oct 2011&lt;/span&gt;&lt;br /&gt;
&lt;strong&gt;Broker-Dealers Fund Markit&#39;s New Commission Management Platform&lt;/strong&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.securitiestechnologymonitor.com/news/markit-brokers-commission-29174-1.html&quot; target=&quot;_blank&quot;&gt;http://www.securitiestechnologymonitor.com/news/markit-brokers-commission-29174-1.html&lt;/a&gt;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>25 Techniques for Javascript Performance Optimization</title>
    <link>https://desalasworks.com/article/javascript-performance-techniques/</link>
    <guid>https://desalasworks.com/article/javascript-performance-techniques/</guid>
    <pubDate>Tue, 21 Feb 2012 15:27:06 GMT</pubDate><category>Code</category><category>UI</category>
    <description>&lt;p&gt;&lt;em&gt;These are some the techniques I use for enhancing the performance of JavaScript, they have mostly been collected over various years of using the language to improve the interactivity of websites and web applications.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;My thanks go out to Marco of &lt;a href=&quot;http://www.zingzing.co.uk/tvguide/&quot; target=&quot;_blank&quot;&gt;zingzing.co.uk&lt;/a&gt; for reminding me of the importance of optimizing JavaScript, and for teaching me some of the techniques below.&lt;/p&gt;
&lt;p&gt;Most of the techniques involve common sense once you have understood the underlying problem. I&#39;ve categorised them into 5 broad categories, each with an underlying problem and solution as follows:&lt;/p&gt;
&lt;h2&gt;1. Avoid interaction with host objects&lt;/h2&gt;
&lt;figure class=&quot;wp-caption alignnone&quot; style=&quot;max-width:600px&quot;&gt;&lt;a href=&quot;https://desalasworks.com/article/javascript-performance-techniques/javascript-host-object-agents.jpg&quot;&gt;&lt;img class=&quot;size-full wp-image-1301&quot; title=&quot;Repeated interaction with host objects will kill your performance.&quot; src=&quot;https://desalasworks.com/article/javascript-performance-techniques/javascript-host-object-agents.jpg&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;234&quot; /&gt;&lt;/a&gt;&lt;figcaption class=&quot;wp-caption-text&quot;&gt;Watch out for these guys. Repeated interaction with them will kill your performance.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;THE PROBLEM:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Native JavaScript is compiled into machine code by most scripting engines offering incredible performance boost, however interaction with host (browser) objects outside the javascript native environment raises unpredictability and considerable performance lag, particularly when dealing with screen-rendered DOM objects or objects which cause Disk I/O (such as WebSQL).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE SOLUTION:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can&#39;t really get away from them, but keep your interaction with host objects to an absolute minimum.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE TECHNIQUES:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;Use CSS classes instead of JavaScript for DOM animation.&lt;/h4&gt;
&lt;p&gt;Its a good habit to try an implement &lt;em&gt;any animation&lt;/em&gt; (or DOM interaction) with CSS if you can get away with it. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions&quot; target=&quot;_blank&quot;&gt;CSS3 Transitions&lt;/a&gt; have been around for a while now, so there are few excuses &lt;em&gt;not&lt;/em&gt; to use them. You can even &lt;a href=&quot;http://stackoverflow.com/questions/5344745/polyfill-shim-for-css-transitions-and-animations&quot; target=&quot;_blank&quot;&gt;use a polyfill&lt;/a&gt; if you are worried about older browsers. Think also of hover menus using the &lt;code&gt;:hover&lt;/code&gt; pseudo-class, or styling and display of elements using &lt;a href=&quot;http://tympanus.net/codrops/2013/05/22/examples-of-pseudo-elements-animations-and-transitions/&quot;&gt;&lt;code&gt;@keyframes&lt;/code&gt;, &lt;code&gt;:before&lt;/code&gt; and &lt;code&gt;:after&lt;/code&gt;&lt;/a&gt;, this is because unlike JavaScript, CSS solutions are heavily optimized by the browser, often down to the level of &lt;a href=&quot;https://www.urbaninsight.com/2013/01/04/improving-html5-app-performance-gpu-accelerated-css-transitions&quot; target=&quot;_blank&quot;&gt;using the GPU for extra processing power&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I realize this might sound like irony (if you want to optimize JavaScript - avoid using it for animation), but the reality is that this technique is executed from within your JavaScript code, it just involves putting more effort on the CSS classes.
&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Use fast DOM traversal with &lt;code&gt;document.getElementById()&lt;/code&gt;.&lt;/h4&gt;
&lt;p&gt;Given the availability of jQuery, it is now easier than ever to produce highly specific selectors based on a combination of tag names, classes and CSS3. You need to be aware that this approach involves several iterations while jQuery loops thorough each subset of DOM elements and tries to find a match. You can improve DOM traversal speeds by picking nodes by ID.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// jQuery will need to iterate many times until it finds the right element&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; button &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;jQuery&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;body div.dialog &gt; div.close-button:nth-child(2)&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// A far more optimized way is to skip jQuery altogether.&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; button &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;dialog-close-button&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// But if you need to use jQuery you can do it this way.&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; button &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;jQuery&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#dialog-close-button&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Store pointer references to in-browser objects.&lt;/h4&gt;
&lt;p&gt;Use this technique to reduce DOM traversal trips by storing references to browser objects during instantiation for later usage. For example, if you are not expecting your DOM to change you should store a reference to DOM or jQuery objects you are going to use when your page is created; if you are building a DOM structure such as a dialog window, make sure you store a few handy reference to DOM objects inside it during instantiation, so you dont need to find the same DOM object over an over again when a user clicks on something or drags the dialog window.&lt;/p&gt;
&lt;p&gt;If you haven&#39;t stored a reference to a DOM object, and you need to iterate inside a function, you can create a local variable containing a reference to that DOM object, this will considerably speed up the iteration as the local variable is stored in the most accessible part of the stack.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Keep your HTML super-lean (get rid of all those useless DIV and SPAN tags)&lt;/h4&gt;
&lt;p&gt;This is extremely important, the time needed to query and modify DOM is directly proportional the the amount and complexity of HTML that needs to be rendered. &lt;/p&gt;
&lt;p&gt;Using half the amount of HTML will roughly double the DOM speed, and since DOM creates the greatest performance drag on any complex JavaScript app, this can produce a considerable improvement. See &lt;a href=&quot;http://developer.yahoo.com/performance/rules.html#min_dom&quot; target=&quot;_blank&quot;&gt;&#39;Reduce Number of DOM Elements&#39; guidance&lt;/a&gt; in Yahoo YSlow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Batch your DOM changes, especially when updating styles.&lt;/h4&gt;When making calls to modify DOM make sure you batch them up so as to avoid repeated screen rendering, for example when applying styling changes. The ideal approach here is to make many styling changes in one go by adding or removing a class, rather than apply each individual style separately. This is because every DOM change prompts the browser to re-render the whole UI using the boxing model. If you need to move an item across the page using X+Y coordinates, make sure that these two are applied at the same time rather than separately. See these examples in jQuery:&lt;p&gt;&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// This will incurr 5 screen refreshes&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;jQuery&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#dialog-window&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;600&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;position&#39;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;absolute&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
                       &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;top&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;200px&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;left&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;200px&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Let jQuery handle the batching&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;jQuery&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#dialog-window&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;token literal-property property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;600px&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
     &lt;span class=&quot;token literal-property property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;400px&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
     &lt;span class=&quot;token literal-property property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;absolute&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
     &lt;span class=&quot;token literal-property property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;200px&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
     &lt;span class=&quot;token literal-property property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;200px&#39;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Or even better use a CSS class.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;jQuery&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#dialog-window&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;mask-aligned-window&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Build DOM separately before adding it to the page.&lt;/h4&gt;
&lt;p&gt;As per the last item, every DOM update requires the whole screen to be refreshed, you can minimize the impact here by building DOM for your widget &#39;off-line&#39; and then appending your DOM structure in one go.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Use buffered DOM inside scrollable DIVs.&lt;/h4&gt;
&lt;p&gt;This is an extension of the fourth point above (Keep HTML super-lean), you can use this technique to remove items from DOM that are not being visually rendered on screen, such as the area outside the viewport of a scrollable DIV, and append the nodes again when they are needed. This will reduce memory usage and DOM traversal speeds. Using this technique the guys at ExtJS have managed to produce an &lt;a href=&quot;http://www.sencha.com/blog/infinite-grid-scrolling-in-ext-js-4&quot; target=&quot;_blank&quot;&gt;infinitely scrollable grid&lt;/a&gt; that doesn&#39;t grind the browser down to a halt.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;2. Manage and Actively reduce your Dependencies&lt;/h2&gt;
&lt;figure class=&quot;wp-caption alignnone&quot; style=&quot;max-width:600px&quot;&gt;&lt;img class=&quot;size-full wp-image-1209&quot; title=&quot;Poorly managed JavaScript dependencies degrade user experience.&quot; src=&quot;https://desalasworks.com/article/javascript-performance-techniques/javascript-depedency-performance.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;281&quot; /&gt;&lt;figcaption class=&quot;wp-caption-text&quot;&gt;Poorly managed JavaScript dependencies degrade user experience.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;THE PROBLEM:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;On-screen visual rendering and user experience is usually delayed while waiting for script dependencies load onto the browser. This is particularly bad for mobile users who have limited bandwidth capacity.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE SOLUTION:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Actively manage and reduce dependency payload in your code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE TECHNIQUES: &lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;Write code that reduces library dependencies to an absolute minimum.&lt;/h4&gt;
&lt;p&gt;Use this approach to reduce the number of libraries your code requires to a minimum, ideally to none, thus creating an incredible boost to the loading times required for your page. &lt;/p&gt;
&lt;p&gt;You can reduce dependency on external libraries by making use of as much in-browser technology as you can, for example you can use &lt;code&gt;document.getElementById(&#39;nodeId&#39;)&lt;/code&gt; instead of &lt;code&gt;jQuery(&#39;#nodeId&#39;)&lt;/code&gt;, or &lt;code&gt;document.getElementsByTagName(&#39;INPUT&#39;)&lt;/code&gt; instead of &lt;code&gt;jQuery(&#39;INPUT&#39;)&lt;/code&gt; which will allow you to get rid of jQuery library dependency.&lt;/p&gt;
&lt;p&gt;If you need complex CSS selectors use &lt;a href=&quot;http://sizzlejs.com/&quot;&gt;Sizzle.js &lt;/a&gt;instead of jQuery, which is far more lightweight (4kb instead of 80kb+).&lt;/p&gt;
&lt;p&gt;Also, before adding any new library to the codebase, evaluate whether or you really need it. Perhaps you are just after 1 single feature in the whole library? If that&#39;s the case then take the code apart and add the feature separately (but don&#39;t forget to check the license and acknowledge author if necessary).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Minimize and combine your code into modules.&lt;/h4&gt;
&lt;p&gt;You can bundle distinct components of your application into combined *.js files and pass them through a javascript minimizer tool such as &lt;a href=&quot;http://code.google.com/closure/&quot;&gt;Google Closures&lt;/a&gt; or &lt;a href=&quot;http://www.crockford.com/javascript/jsmin.html&quot;&gt;JsMin &lt;/a&gt;that gets rid of comments and whitespacing.&lt;/p&gt;
&lt;p&gt;The logic here is that a single minimized request for a 10Kb .js file &lt;a href=&quot;http://developer.yahoo.com/performance/rules.html#num_http&quot;&gt;completes faster &lt;/a&gt;than 10 requests for files that are 1-2kb each due to lower bandwidth usage and network latency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Use a post-load dependency manager for your libraries and modules.&lt;/h4&gt;
&lt;p&gt;Much of your functionality will not need to be implemented until after the page loads. By using a dependency manager (such as &lt;a href=&quot;http://requirejs.org/&quot; target=&quot;_blank&quot;&gt;RequireJS&lt;/a&gt; or &lt;a href=&quot;http://webpack.github.io/&quot; target=&quot;_blank&quot;&gt;Webpack&lt;/a&gt;) to load your scripts after the page has completed rendering you are giving the user a few extra seconds to familiarise themselves with the layout and options before them. &lt;/p&gt;
&lt;p&gt;Make sure that your dependency manager can &#39;remember&#39; which dependencies have been loaded so you dont end up loading the same libraries twice for each module. See guidance for &lt;a href=&quot;http://developer.yahoo.com/performance/rules.html#postload&quot;&gt;Pre-Loading and Post-loading&lt;/a&gt; in Yahoo YSLow, and be mindful about loading only what is necessary at each stage of the user journey.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Maximise use of caching (eTags, .js files, etc).&lt;/h4&gt;
&lt;p&gt;Cache is your best friend when it comes to loading pages faster. Try to maximise the use of cache by &lt;a href=&quot;http://developer.yahoo.com/blogs/ydn/posts/2007/07/high_performanc_11/&quot;&gt;applying ETags liberally&lt;/a&gt; and putting all your javascript into files ending in *.js found in static URI locations (avoid dynamic Java/C# bundle generations ending with *.jsp and *.ashx) . This will tell the browser to use the locally cached copy of your scripts for any pages loaded after the initial one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Move scripts to the end of the page (not recommended).&lt;/h4&gt;
&lt;p&gt;This is the lazy way of handling post-load dependencies, ideally you should implement a post-load dependency manager, but if you only have one or two scripts to load into the page you can add them at the very end of the HTML document where the browser will start loading them after the page is rendered, giving the user a few extra seconds of interaction.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;3. Be disciplined with event binding&lt;/h2&gt;
&lt;figure class=&quot;wp-caption alignnone&quot; style=&quot;max-width:600px&quot;&gt;&lt;img class=&quot;size-full wp-image-1244&quot; title=&quot;Be a ninja when using event handling.&quot; src=&quot;https://desalasworks.com/article/javascript-performance-techniques/javascript-event-handling.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;250&quot; /&gt;&lt;figcaption class=&quot;wp-caption-text&quot;&gt;Be a ninja when using event handling.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;THE PROBLEM:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Browser and custom event handlers are an incredible tool for improving user experience and reducing the depth of the call stack (so you avoid having a function calling a function which calls another function etc), but since they are hard to track due to their &#39;hidden&#39; execution they can fire many times repeatedly and quickly get out of hand, causing performance degradation. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE SOLUTION:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Be mindful and disciplined when creating event handlers. Get to know your weapons too, if you are using a framework then find out what&#39;s going on underneath the hood.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE TECHNIQUES:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;Use event binding but do it carefully.&lt;/h4&gt;
&lt;p&gt;Event binding is great for creating responsive applications. However, it is important that you walk through the execution and various user journeys &lt;em&gt;to make sure they are not firing multiple times&lt;/em&gt; or using up unnecessary resources behind the scenes. Comment your code well so they next guy (which may be you a few months down the line) can follow what&#39;s going on and avoid this issue as well.&lt;/p&gt;
&lt;p&gt;If you are using &lt;u&gt;AngularJS&lt;/u&gt; make sure you are getting &lt;a href=&quot;http://www.alexkras.com/11-tips-to-improve-angularjs-performance/#watchers&quot; target=&quot;_blank&quot;&gt;rid of unnecessary &#39;watchers&#39;&lt;/a&gt;. These are background events that involve heavy processing and will slow down your app, particularly on mobile devices.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Pay special attention event handlers that fire in quick succession (ie, &#39;mousemove&#39;).&lt;/h4&gt;
&lt;p&gt;Browser events such as &#39;mousemove&#39; and &#39;resize&#39; are executed in quick succession up to &lt;em&gt;several hundred times each second&lt;/em&gt;, this means that you need to ensure that an event handler bound to either of these events is coded optimally and can complete in less than 2-3 milliseconds. &lt;/p&gt;
&lt;p&gt;Any overhead greater than that will create a patchy user experience, specially in browsers such as IE that have poor rendering capabilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Remember to unbind events when they are not needed.&lt;/h4&gt;
&lt;p&gt;Unbinding events is almost as important as binding them. When you add a new event handler to your code make sure that you provide for it to stop firing when it is no longer needed, ideally using once-off execution constructs like &lt;em&gt;jQuery.one()&lt;/em&gt; or coding in the unbind behaviour at that point. This will avoid you having the same handler bound multiple times degrading performance, or events firing when they are no longer needed, this often points to memory leaks in your app as pointed out by the &lt;a href=&quot;https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html&quot; target=&quot;_blank&quot;&gt;React developers in this blog post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are using jQuery to bind and unbind events, make sure your selector points to a unique node, as a loose selector can create or remove more handlers than you intend to.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Learn about event bubbling.&lt;/h4&gt;
&lt;p&gt;If you are going to use event handlers, it is important that you understand how event bubbling propagates an event up the DOM tree to every ancestor node. You can use this knowledge to limit your dependency on event bubbling with approaches such as jQuery.live() and jQuery.delegate() that require full DOM traversal upon handling each event, or to  stop event bubbling for improved performance. See this &lt;a href=&quot;http://www.alfajango.com/blog/the-difference-between-jquerys-bind-live-and-delegate/&quot; target=&quot;_blank&quot;&gt;great post&lt;/a&gt; on the subject.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Use &#39;mouseup&#39; instead of &#39;click&#39;.&lt;/h4&gt;
&lt;p&gt;Remember that user interaction via the mouse or keyboard fires several events in a specific order. It is useful to remember the order in which these events fire so you can squeeze in your functionality&lt;em&gt; before anything else gets handled, &lt;/em&gt;including native browser event handlers.&lt;/p&gt;
&lt;p&gt;A good example of this is to bind your functionality to the &#39;mouseup&#39; event which fires &lt;em&gt;before&lt;/em&gt; the &#39;click&#39; event, this can produce a surprising performance boost in older browsers such as IE, making the difference between handling every interaction or missing some of the action if the user triggers clicks many times in succession.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;4. Maximise the efficiency of your iterations&lt;/h2&gt;
&lt;figure class=&quot;wp-caption alignnone&quot; style=&quot;max-width:600px&quot;&gt;&lt;img class=&quot;size-full wp-image-1237&quot; title=&quot;String concatenation performance becomes critical during long iterations.&quot; src=&quot;https://desalasworks.com/article/javascript-performance-techniques/javascript-string-performance.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;227&quot; /&gt;&lt;figcaption class=&quot;wp-caption-text&quot;&gt;Performance becomes critical during long iterations.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;THE PROBLEM:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Due to the processing time used, iterations are usually the first places where you can address performance flaws in an application.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE SOLUTION:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Get rid of unnecessary loops and calls made inside loops.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE TECHNIQUES:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;Harness the indexing power of JavaScript objects.&lt;/h4&gt;
&lt;p&gt;Native JavaScript objects &lt;code&gt;{}&lt;/code&gt; can be used as powerful &lt;a href=&quot;http://en.wikipedia.org/wiki/Hash_table&quot; target=&quot;_blank&quot;&gt;Hashtable data structures&lt;/a&gt; with quick-lookup indexes to store references to other objects, acting similarly to the way database indexes work for speeding up search operations by preventing needless looping. &lt;/p&gt;
&lt;p&gt;So why bother iterating to find something? You can simply use a plain object as an index (think of a phone-book) to get to your desired item quickly and efficiently. Here is an example as follows:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; data &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token string-property property&quot;&gt;&quot;joeb&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;joe&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;surname&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;bloggs&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;29&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;token string-property property&quot;&gt;&quot;marys&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;mary&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;surname&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;smith&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;25&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;token comment&quot;&gt;// another 1000 records&lt;/span&gt;
         &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token function-variable function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;index&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;username&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
         &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Harness the power of array structures with push() and pop() and shift().&lt;/h4&gt;
&lt;p&gt;Array &lt;code&gt;push()&lt;/code&gt; &lt;code&gt;pop()&lt;/code&gt; and &lt;code&gt;shift()&lt;/code&gt; instructions have &lt;a href=&quot;http://stackoverflow.com/questions/8423493/what-is-the-performance-of-objects-arrays-in-javascript-specifically-for-googl/8584173#8584173&quot; target=&quot;_blank&quot;&gt;minimal processing overhead&lt;/a&gt; (20x that of object manipulation) due to being language constructs closely related to their low-level assembly language counterparts. In addition, using &lt;a href=&quot;http://en.wikipedia.org/wiki/Queue_(abstract_data_type)&quot; target=&quot;_blank&quot;&gt;queue&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Stack_(data_structure)&quot; target=&quot;_blank&quot;&gt;stack&lt;/a&gt; data structures can help simplify your code logic and get rid of unnecessarily loops. See more on the topic in &lt;a href=&quot;http://jclaes.blogspot.com/2011/07/stacks-and-queues-in-javascript.html&quot; target=&quot;_blank&quot;&gt;this article&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Take advantage of reference types.&lt;/h4&gt;
&lt;p&gt;JavaScript, much like other C-based languages, has both &lt;a href=&quot;http://docstore.mik.ua/orelly/webprog/jscript/ch11_02.htm&quot; target=&quot;_blank&quot;&gt;primitive and reference value types&lt;/a&gt;. Primitive types such as strings, booleans and integers are copied whenever they are passed into a new function, however reference types such as arrays, objects and dates are passed only as a light-weight reference.You can use this to get the most performance out of recursive functions, such as by passing a DOM node reference recursively to minimise DOM traversal, or by passing a reference parameter into a function that executes within an iteration. Also, remember that comparing object references is far more efficient than comparing strings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Use &lt;code&gt;Array.prototype.join()&lt;/code&gt; for string concatenation.&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;PLEASE NOTE:&lt;/strong&gt; This article was first written in 2012 when string concatenation was a hazard to be aware of. However, these days most JavaScript engines have compilation tricks that have made this issue obsolete. The wording below is only really relevant for historical purposes.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Joining strings using the plus sign (ie &lt;code&gt;var ab = &#39;a&#39; + &#39;b&#39;;&lt;/code&gt;) creates performance issues in IE when used within an iteration. This is because, like Java and C#, &lt;a href=&quot;http://stackoverflow.com/questions/51185/are-javascript-strings-immutable-do-i-need-a-string-builder-in-js&quot; target=&quot;_blank&quot;&gt;JavaScript uses unmutable strings&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Basically, when you concatenate two strings, a third string is constructed for gathering the results with its own object instantiation logic and memory allocation. While other browsers have various compilation tricks around this, IE is particularly bad at it.A far better approach is to use an array for carrying out the donkey work, creating an array outside the loop, using &lt;code&gt;push()&lt;/code&gt; to add items into to the array and then a &lt;code&gt;join()&lt;/code&gt; to output the results. See &lt;a href=&quot;http://www.sitepen.com/blog/2008/05/09/string-performance-an-analysis/&quot; target=&quot;_blank&quot;&gt;this link&lt;/a&gt; for a more in-depth article on the subject.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;5. Become friends with the JavaScript lexicon&lt;/h2&gt;
&lt;figure class=&quot;wp-caption alignnone&quot; style=&quot;max-width:600px&quot;&gt;&lt;img class=&quot;size-full wp-image-1239&quot; title=&quot;Become a friend of the ECMA Standard and it make your code faster.&quot; src=&quot;https://desalasworks.com/article/javascript-performance-techniques/javascript-lexical-performance.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;302&quot; /&gt;&lt;figcaption class=&quot;wp-caption-text&quot;&gt;Become a friend of the ECMA Standard and it make your code faster.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;THE PROBLEM:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Due to its loosely-typed and free-for-all nature, JavaScript can be written using a very limited subset of lexical constructs with no discipline or controls applied to its use. Using simple function patterns repetitively often leads to poorly thought-out &#39;spaghetti&#39; code that is inefficient in terms of resource use.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE SOLUTION:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Learn when and how to apply the constructs of the &lt;a href=&quot;http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf&quot;&gt;ECMAScript language standard&lt;/a&gt; to maximise performance.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;THE TECHNIQUES:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;h4&gt;Shorten the scope chain&lt;/h4&gt;
&lt;p&gt;In JavaScript, whenever a function is executed, a set of first order variables are instantiated as part of that function. These include the immediate scope of a function (the &lt;code&gt;this&lt;/code&gt; variable) with its own scope chain, the &lt;code&gt;arguments&lt;/code&gt; of the function and all  locally-declared variables.&lt;/p&gt;
&lt;p&gt;If you try and access a globally-declared variable or a closure further up the scope chain, it will take extra effort to traverse up the chain every level util the compiler can wire up the variable you are after. You can thus improve execution by reducing the depth of the call stack, and by only using the local scope (&lt;code&gt;this&lt;/code&gt;), the &lt;code&gt;arguments&lt;/code&gt; of the function, as well as locally declared variables. &lt;a href=&quot;http://homepage.mac.com/rue/JS_Optimization_Techniques/&quot; target=&quot;_blank&quot;&gt;This article&lt;/a&gt; explains the matter further.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Make use of &#39;this&#39;, by passing correct scope using &#39;call&#39; and &#39;apply&#39;.&lt;/h4&gt;
&lt;p&gt;This is particularly useful for writing asynchronous code using callbacks, however it also improves performance because you are not relying on global or &lt;a href=&quot;http://www.javascriptkit.com/javatutors/closures.shtml&quot; target=&quot;_blank&quot;&gt;closure variables&lt;/a&gt; held further up the scope chain. You can get the most out of the scope variable (&lt;code&gt;this&lt;/code&gt;) by rewiring it using the &lt;a href=&quot;http://odetocode.com/blogs/scott/archive/2007/07/05/function-apply-and-function-call-in-javascript.aspx&quot; target=&quot;_blank&quot;&gt;special call() and apply() methods&lt;/a&gt; that are built into each function. See the example below:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function-variable function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token function-variable function&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;token function&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; john &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;john&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
john&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &#39;john&#39; gets alerted because we rewired &#39;this&#39;.&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Learn and use native functions and constructs.&lt;/h4&gt;
&lt;p&gt;ECMAScript provides a whole host of native constructs that save you having to write your own algorithms or rely on host objects. Some examples include &lt;code&gt;Math.floor()&lt;/code&gt;, &lt;code&gt;Math.round()&lt;/code&gt;, &lt;code&gt;(new Date()).getTime()&lt;/code&gt; for timestamps, &lt;code&gt;String.prototype.match()&lt;/code&gt; and &lt;code&gt;String.prototype.replace()&lt;/code&gt; for regexes, &lt;code&gt;parseInt(n, radix)&lt;/code&gt; for changing numeral systems, &lt;code&gt;===&lt;/code&gt; instead of &lt;code&gt;==&lt;/code&gt; for faster type-based comparsion, &lt;code&gt;instanceof&lt;/code&gt; for checking type up the hierarchy, &lt;code&gt;&amp;amp;&lt;/code&gt; and &lt;code&gt;|&lt;/code&gt; for &lt;a href=&quot;https://developer.mozilla.org/en/JavaScript/Reference/Operators/Bitwise_Operators&quot; target=&quot;_blank&quot;&gt;bitwise comparisons&lt;/a&gt;. And the list goes on and on. &lt;/p&gt;
&lt;p&gt;Make sure you use all these instead of trying to work out your own algorithms as you will not only be reinventing the wheel but affecting performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;h4&gt;Use &#39;switch&#39; instead of lengthy &#39;if-then-else&#39; statements.&lt;/h4&gt;
&lt;p&gt;This is because  &#39;switch&#39; statements can be &lt;a href=&quot;http://en.wikipedia.org/wiki/Switch_statement#Compilation&quot;&gt;optimized more easily during compilation&lt;/a&gt;. There is an interesting article in O&#39;Reily about using &lt;a href=&quot;http://oreilly.com/server-administration/excerpts/even-faster-websites/writing-efficient-javascript.html#the_switch_statement&quot; target=&quot;_blank&quot;&gt;this approach with JavaScript&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</description>
  </item>
  <item>
    <title>WP Simple SpamCheck</title>
    <link>https://desalasworks.com/wp-simple-spamcheck/</link>
    <guid>https://desalasworks.com/wp-simple-spamcheck/</guid>
    <pubDate>Mon, 06 Feb 2012 01:48:04 GMT</pubDate><category>CMS</category><category>Code</category>
    <description>&lt;p&gt;&lt;em&gt;This plugin allows WordPress to block over 95% of comments using a time-based hash.&lt;/em&gt;&lt;em&gt; &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This allows for a minimum sanity check and yet should remove almost all spam comments without the need to sign up to any third party APIs.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You are now welcome to install and use this WordPress Plugin I developed out of frustration of having to sign up and pay for a key to the &lt;a href=&quot;https://akismet.com/signup/&quot; target=&quot;_blank&quot;&gt;Akismet API&lt;/a&gt; services, and yet knowing that a simple time-based input validation could help get rid of the majority of my spam comments.&lt;/p&gt;
&lt;figure class=&quot;wp-caption alignnone&quot; style=&quot;max-width:600px&quot;&gt;&lt;a href=&quot;https://desalasworks.com/wp-simple-spamcheck/screenshot-1.png&quot;&gt;&lt;img class=&quot;size-large wp-image-1442&quot; title=&quot;screenshot-1&quot; src=&quot;https://desalasworks.com/wp-simple-spamcheck/screenshot-1-600x420.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;420&quot; /&gt;&lt;/a&gt;&lt;figcaption class=&quot;wp-caption-text&quot;&gt;This is what the plugin looks like once installed.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;So far I have been using this plugin myself for the past 12 months and I am very happy with the results. I normally receive around 400-600 spam comments a week and this has cut that down to an average of 1-2 which is far more manageable.&lt;/p&gt;
&lt;p&gt;The solution is pretty low-tech, it only took about 2 days to put it together using some time-validation techniques I&#39;ve successfully used in the past for one of my other websites (&lt;a href=&quot;http://www.valuetrader.info/Login.aspx&quot;&gt;www.valuetrader.info&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The plugin is pretty effective given the lack of sophistication employed by the majority of spam bots however it is not very advanced and for that reason some spam comments may still make it through.&lt;/p&gt;
&lt;p&gt;To install follow these instructions:&lt;/p&gt;
&lt;p&gt;1. Download the file &lt;a href=&quot;https://desalasworks.com/wp-simple-spamcheck/wp-simple-spamcheck.zip&quot;&gt;wp-simple-spamcheck.zip&lt;/a&gt; to your desktop.&lt;br /&gt;
2. Open the &#39;Plugins&#39; section of your site&lt;br /&gt;
3. Click on &#39;Add New&#39; and then &#39;Upload&#39;&lt;br /&gt;
4. Select the &#39;&lt;em&gt;wp-simple-spamcheck.zip&lt;/em&gt;&#39; file you just saved and press &#39;Install Now&#39;.&lt;br /&gt;
5. Click &#39;Apply&#39; once the installation has completed.&lt;br /&gt;
6. Hopefully, the &#39;(Spamcheck Enabled)&#39; message should appear when entering comments.&lt;/p&gt;
&lt;p&gt;Please be aware that some templates may not be able to implement this spam check plugin, if the &#39;(Spamcheck Enabled)&#39; message does not appear then just uninstall and search for a different plugin from the &lt;a href=&quot;http://wordpress.org/extend/plugins/search.php?q=spam&quot; target=&quot;_blank&quot;&gt;other available options&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you have installed this plugin and you find it useful. Please &lt;a href=&quot;http://wordpress.org/extend/plugins/wp-simple-spamcheck/&quot;&gt;&lt;strong&gt;give it a rating&lt;/strong&gt;&lt;/a&gt; in the Wordpress plugin website so that other users can see it.&lt;/p&gt;
&lt;p&gt;If you have any other problems just drop me a line here.&lt;/p&gt;
</description>
  </item>
  <item>
    <title>Object-Oriented JavaScript Inheritance</title>
    <link>https://desalasworks.com/article/object-oriented-javascript-inheritance/</link>
    <guid>https://desalasworks.com/article/object-oriented-javascript-inheritance/</guid>
    <pubDate>Thu, 29 Sep 2011 16:05:25 GMT</pubDate><category>Code</category><category>UI</category>
    <description>&lt;p&gt;&lt;em&gt;This is simple but crucial stuff in JavaScript. Its easy to forget how to do object-oriented inheritance from scratch when you are dealing with several JS frameworks and each of them has pre-built methods that support this functionality in a slightly different way.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;JavaScript is a functional language that uses prototypal inheritance. That means you can use classical inheritance such as that supported by Java and C#, however you need to be disciplined about the way you write code and need do a couple of things every time you add a class to your type hierarchy.&lt;/p&gt;
&lt;p&gt;&lt;img class=&quot;alignnone size-full wp-image-1015&quot; title=&quot;tmp2248&quot; src=&quot;https://desalasworks.com/article/object-oriented-javascript-inheritance/tmp2248.png&quot; alt=&quot;&quot; width=&quot;600&quot; height=&quot;320&quot; /&gt;&lt;/p&gt;
&lt;p&gt;When creating a new class, we are essentially creating a function and assigning a new instance of another function as the prototype. This is the basis of &#39;prototypal&#39; inheritance, ie. if you are dealing with &#39;Dog&#39; type that inherits from an &#39;Animal&#39; class, the template for your dog is a newly created instance of animal.&lt;/p&gt;
&lt;p&gt;For Example:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create a new class called &#39;Animal&#39;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;Animal&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Create an instance of the &#39;Animal&#39;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; anAnimal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Animal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Create a class called &#39;Dog&#39;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;Dog&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Assign the template&lt;/span&gt;
&lt;span class=&quot;token class-name&quot;&gt;Dog&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; anAnimal&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Instantiate the dog&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lassie &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Dog&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Abstracting inheritance&lt;/h2&gt;
&lt;p&gt;I&#39;ve created a simple static method called &#39;extend&#39; on the Object class. Most frameworks do this in one shape or another (ie ExtJS uses &lt;a href=&quot;http://www.sencha.com/learn/legacy/Tutorial:Extending_Ext_Class&quot; target=&quot;_blank&quot;&gt;Ext.extend()&lt;/a&gt;, John Resig likes to use &lt;a href=&quot;http://ejohn.org/blog/simple-javascript-inheritance/&quot; target=&quot;_blank&quot;&gt;Class.extend()&lt;/a&gt; method, Mootools uses &lt;a href=&quot;http://mootools.net/docs/core/Class/Class&quot; target=&quot;_blank&quot;&gt;new Class(properties) &lt;/a&gt;approach etc).&lt;/p&gt;
&lt;p&gt;A &#39;static&#39; method means that only the &#39;Object&#39; class template will have it, so we do not pass it over to our children through inheritance. See the following code:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create a static &#39;extends&#39; method on the Object class&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// This allows us to extend existing classes&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// for classical object-oriented inheritance&lt;/span&gt;
Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;extend&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;superClass&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; definition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;subClass&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    subClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;superClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; prop &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; definition&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        subClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; definition&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; subClass&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This allows us to simplify the process of using object-oriented inheritance by abstracting the prototype assignment into this separate function call.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create an &#39;Animal&#39; class by extending&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// the &#39;Object&#39; class with our magic method&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Object&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;move&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;moving...&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Create a &#39;Dog&#39; class that extends &#39;Animal&#39;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Dog &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Animal&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;bark&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;woof&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Instantiate Lassie&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lassie &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Dog&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// She can move AND bark!&lt;/span&gt;
lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bark&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Adding Constructors&lt;/h2&gt;
&lt;p&gt;But, we seem to have forgotten one thing. What about constructors?&lt;/p&gt;
&lt;p&gt;JavaScript uses the function itself as the constructor for a new object. Thus, when we created the Animal object above we could have simply added some sample code to its constructor as follows:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Assign the name of the animal when it gets instantiated&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lassie &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Animal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Lassie&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;My pets name is: &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thus we can augment our class creation methodology using the same idea:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create a &#39;Subclass&#39; with a constructor&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; SubClass &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;SuperClass&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;parameter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;x &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; parameter&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;method1&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Instantiate it&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; subClass &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;SubClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;value&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;subClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;x&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In order to allow this kind of notation, we can modify our &#39;extend&#39; method to take care of this special &#39;constructor&#39; function. This is done as follows:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create a static &#39;extends&#39; method on the Object class&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// This allows us to extend existing classes&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// for classical object-oriented inheritance&lt;/span&gt;
Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;extend&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;superClass&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; definition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;subClass&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Our constructor becomes the &#39;subclass&#39;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;definition&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;constructor &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        subClass &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; definition&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;constructor&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    subClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;superClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; prop &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; definition&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    	&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;constructor&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
            subClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; definition&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; subClass&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And put it to use by writing minimal code that is meaningful to read and leaves the object-creation abstraction sitting behind the scenes:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create the &#39;Animal&#39; class by extending&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// the &#39;Object&#39; class with our magic method&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// this time using a constructor&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Object&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;moving...&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Instantiate Lassie (as an animal)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lassie &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Animal&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Lassie&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Now lassie has a name which is&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// defined inside the object constructor&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;My pets name is: &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Calling constructors through the inheritance chain.&lt;/h2&gt;
&lt;p&gt;Now we have come up against a small problem, our &#39;Animal&#39; class can have a constructor, but its child class &#39;Dog&#39; has no way to call this constructor so it can take advantage of the logic for instantiating all animals.&lt;/p&gt;
&lt;p&gt;In order to do this we are going to add a special &#39;superClass&#39; property to all of our classes automatically, then use the &lt;a href=&quot;http://odetocode.com/blogs/scott/archive/2007/07/05/function-apply-and-function-call-in-javascript.aspx&quot; target=&quot;_blank&quot;&gt;magic &#39;call&#39; function&lt;/a&gt; to call this using the context of the dog instance (to put it in plain english, this will make each &#39;Dog&#39; run the logic for an &#39;Animal&#39;).&lt;/p&gt;
&lt;p&gt;Lets see, all together now:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create a static &#39;extends&#39; method on the Object class&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// This allows us to extend existing classes&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// for classical object-oriented inheritance&lt;/span&gt;
Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;extend&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;superClass&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; definition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;subClass&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Our constructor becomes the &#39;subclass&#39;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;definition&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;constructor &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        subClass &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; definition&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;constructor&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    subClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;superClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; prop &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; definition&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    	&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;constructor&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
            subClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; definition&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Keep track of the parent class&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// so we can call its constructor too&lt;/span&gt;
    subClass&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;superClass &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; superClass&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; subClass&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Create the &#39;Animal&#39; class by extending&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// the &#39;Object&#39; class with our magic method&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// this time using a constructor&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Animal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Object&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;moving...&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Create a &#39;Dog&#39; class that inherits from it&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Dog &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Animal&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token comment&quot;&gt;// Remember to call the super class constructor&lt;/span&gt;
        Dog&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;superClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;bark&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;woof&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Instantiate Lassie&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lassie &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Dog&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Lassie&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// She can move AND bark AND has a name!&lt;/span&gt;
lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bark&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;My pets name is: &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;adding-intefaces&quot;&gt;Multiple inheritance using Interfaces&lt;/h2&gt;
&lt;p&gt;Now its possible to add support for &lt;a href=&quot;http://en.wikipedia.org/wiki/Multiple_inheritance&quot; target=&quot;_blank&quot;&gt;multiple inheritance&lt;/a&gt; to our object creation syntax in Javascript. In single-inheritance object-oriented languages such as Java and C#, multiple inheritance (inheriting properties and methods from more than one class chain) is done using &lt;a href=&quot;http://en.wikipedia.org/wiki/Interface_(computing)#Software_interfaces_in_object_oriented_languages&quot; target=&quot;_blank&quot;&gt;Interfaces&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The implementation is a bit more crude than in Java or C#, the reason why is because Javascript, unlike these languages, is not compiled so we cant throw compilation-time errors. This means that when we implement an interface we are limited to checking that the appropriate members are there at runtime and if not we through an error.&lt;/p&gt;
&lt;p&gt;So, lets start first with our intended usage for Interfaces:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; SubClass &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;SuperClass&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;token function-variable function&quot;&gt;method1&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
         &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;something&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;implement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Inteface1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Interface2 &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Going by this approach, we need to create a method &#39;implement&#39; for every class, since in Javascript our classes are instances of the &#39;Function&#39; object, this means adding this method to Function.prototype.&lt;/p&gt;
&lt;p&gt;The code does start to be a bit hairy from this point, its important to point out that the context of this function call (ie &lt;strong style=&quot;color: blue; font-family: Courier New, sans serif;&quot;&gt;this&lt;/strong&gt;) is the class that we are testing for implementation of a particular interface.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token class-name&quot;&gt;Function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;implement&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Loop through each interface passed in and then check&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// that its members are implemented in the context object (this)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; arguments&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
         &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; interf &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; arguments&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
         &lt;span class=&quot;token comment&quot;&gt;// Is the interface a class type?&lt;/span&gt;
         &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;interf&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;constructor &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
             &lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;prop &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; interf&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                 &lt;span class=&quot;token comment&quot;&gt;// Check methods and fields vs context object (this)&lt;/span&gt;
                 &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;interf&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;constructor &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Function&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                     &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
                          &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;constructor &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; Function&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                          &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Method [&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; prop
                               &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;] missing from class definition.&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
                     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                     &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;prop&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
                          &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Field [&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; prop
                               &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;] missing from class definition.&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
                     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
                 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
             &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
         &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// Remember to return the class being tested&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And there you have it! Its important to point out that this is one of many ways to abstract object-orientation in Javascript. There are different approaches, and as a programmer it helps to pick one you are more comfortable with. Personally, I like this approach because of its simplicity, readability, and ease of use:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create a &#39;Mammal&#39; interface&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Mammal &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;nurse&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Create the &#39;Pet&#39; interface&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Pet &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;trick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Create a &#39;Dog&#39; class that inherits from &#39;Animal&#39;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// and implements the &#39;Mammal&#39; and &#39;Pet&#39; interfaces&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; Dog &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Animal&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;token function-variable function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          Dog&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;superClass&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
     &lt;span class=&quot;token function-variable function&quot;&gt;bark&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;woof&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
     &lt;span class=&quot;token function-variable function&quot;&gt;nurse&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;baby&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          baby&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;food &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
     &lt;span class=&quot;token function-variable function&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;trick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;trick &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;ing...&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;implement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Mammal&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Pet&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Instantiate it&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; lassie &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Dog&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Lassie&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;move&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bark&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;nurse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Dog&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Baby&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;fetch&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;My pets name is: &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; lassie&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</description>
  </item>
</channel>
</rss>
