<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title></title>
 <link href="http://fgnass.github.com/blog.atom" rel="self"/>
 <link href="http://fgnass.github.com"/>
 <updated>2014-05-28T01:12:39-07:00</updated>
 <id>http://fgnass.github.com</id>
 <author>
   <name>Felix Gnass</name>
   <email>fgnass@gmail.com</email>
 </author>

 
 <entry>
   <title>Local Wildcard Domains on OS X</title>
   <link href="http://fgnass.github.com/2013/02/26/wildcard-domains-on-osx.html"/>
   <updated>2013-02-26T00:00:00-08:00</updated>
   <id>hhttp://fgnass.github.com/2013/02/26/wildcard-domains-on-osx</id>
   <content type="html">&lt;p&gt;This post shows how to map &lt;code&gt;*.dev&lt;/code&gt; domains to localhost and make them accessible from within VirtualBox.&lt;/p&gt;

&lt;h2 id=&quot;adding_an_ip_alias&quot;&gt;Adding an IP alias&lt;/h2&gt;

&lt;p&gt;By default VirtualBox maps the IP &lt;code&gt;10.0.2.2&lt;/code&gt; to the host’s loopback interface. So instead of mapping &lt;code&gt;*.dev&lt;/code&gt;domains to &lt;code&gt;127.0.0.1&lt;/code&gt; as one would normally do we let them resolve to 10.0.2.2 and set up an IP-Alias for the loopback interface. In order to permanently add the alias we have to put this &lt;a href=&quot;https://gist.github.com/fgnass/5037138/raw/676369616ee8ba5f8c77a9b32d2a60ecd05edaf0/ipalias.plist&quot;&gt;plist&lt;/a&gt; file into the &lt;code&gt;/Library/LaunchDaemons/&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Download the gist
sudo curl https://gist.github.com/fgnass/5037138/raw/676369616ee8ba5f8c77a9b32d2a60ecd05edaf0/ipalias.plist -o /Library/LaunchDaemons/ipalias.plist

# Let launchd execute the command
sudo launchctl load /Library/LaunchDaemons/ipalias.plist&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To verify that the command was executed successfully run &lt;code&gt;sudo ifconfig lo0 | grep 10.0.2.2&lt;/code&gt; which should display the following output:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;inet 10.0.2.2 netmask 0xff000000&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;installing_a_dns_forwarder&quot;&gt;Installing a DNS forwarder&lt;/h2&gt;

&lt;p&gt;To actually resolve the &lt;code&gt;*.dev&lt;/code&gt; domains we install &lt;a href=&quot;http://www.thekelleys.org.uk/dnsmasq/doc.html&quot;&gt;dnsmasq&lt;/a&gt; a lightweight DNS forwarder:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Install dnsmasq via homebrew
brew install dnsmasq

# Resolve *.dev domains to 10.0.2.2
echo &amp;quot;address=/.dev/10.0.2.2&amp;quot; &amp;gt; `brew --prefix`/etc/dnsmasq.conf

# Launch on Startup
sudo cp `brew --prefix dnsmasq`/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

# Use dnsmasq as nameserver
sudo bash -c &amp;#39;mkdir /etc/resolver &amp;amp;&amp;amp; echo &amp;quot;nameserver 127.0.0.1&amp;quot; &amp;gt; /etc/resolver/dev&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You should now be able to ping &lt;code&gt;foo.dev&lt;/code&gt; as well as any other &lt;code&gt;.dev&lt;/code&gt; domain.&lt;/p&gt;

&lt;h2 id=&quot;setting_up_the_nameserver_in_your_virtual_machines&quot;&gt;Setting up the nameserver in your Virtual Machines&lt;/h2&gt;

&lt;p&gt;The last step is to tell your VMs to use &lt;code&gt;10.0.2.2&lt;/code&gt; as DNS-Server. Under Windows this looks like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/dns.jpg&quot; alt=&quot;Screenshot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you spot an error please &lt;a href=&quot;https://github.com/fgnass/fgnass.github.com/issues&quot;&gt;create an issue&lt;/a&gt; or drop me a line on &lt;a href=&quot;http://twitter.com/fgnass&quot;&gt;twitter&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Serving PHP files with Yeoman</title>
   <link href="http://fgnass.github.com/2012/08/30/yeoman.html"/>
   <updated>2012-08-30T00:00:00-07:00</updated>
   <id>hhttp://fgnass.github.com/2012/08/30/yeoman</id>
   <content type="html">&lt;p&gt;I recently did some PHP development and thought it would be nice if I could use &lt;a href=&quot;http://yeoman.io&quot;&gt;Yeoman’s&lt;/a&gt; built-in development server to serve dynamic files, too.&lt;/p&gt;

&lt;p&gt;The first step was to install &lt;code&gt;php-cgi&lt;/code&gt; which isn’t included with OS X.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&#39;/images/yeoman.jpg&#39; style=&#39;float:left;margin:0 10px 0 -10px; border:none&#39; /&gt;&lt;/p&gt;

&lt;p&gt;The next step was to add a middleware to Yeoman’s server in order to invoke the PHP interpreter for all files ending with &lt;code&gt;.php&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I found the &lt;a href=&quot;https://github.com/TooTallNate/node-cgi&quot;&gt;node-cgi&lt;/a&gt; module that Nathan (&lt;a href=&quot;https://twitter.com/tootallnate&quot;&gt;@TooTallNate&lt;/a&gt;) had written to serve the GitWeb interface through Node, but unfortunately node-cgi only handles scripts with a shebang that are located in a &lt;code&gt;cgi-bin&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;I needed a module that would serve scripts from arbitrary locations and choose the interpreter based on the file’s extension. As it should also support welcome-files so I decided to &lt;a href=&quot;https://github.com/fgnass/gateway&quot;&gt;roll my own&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While Yeoman was now able to serve PHP files, one important aspect was still missing: The server had to inject the liverelaad snippet into the response that was generated by the PHP interpreter.&lt;/p&gt;

&lt;p&gt;Hence I wrote a second middleware called &lt;a href=&quot;https://github.com/fgnass/gateway&quot;&gt;tamper&lt;/a&gt;. What tamper does is that it temporarily overwrites the &lt;code&gt;write()&lt;/code&gt;, &lt;code&gt;writeHead()&lt;/code&gt; and &lt;code&gt;end()&lt;/code&gt; methods of the ServerResponse object. Before the headers are sent to the client, tamper invokes a callback function that decides whether the response body should be captured or whether it should be streamed to the client without further tampering.&lt;/p&gt;

&lt;p&gt;With these two little patches &lt;code&gt;yeoman server&lt;/code&gt; now happily serves PHP files. You can watch the screencast below to see the live reloading in action:&lt;/p&gt;

&lt;p&gt;&lt;video controls=&#39;true&#39; src=&#39;/assets/yeoman.mp4&#39; /&gt;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Better than templates</title>
   <link href="http://fgnass.github.com/2012/02/22/mkay.html"/>
   <updated>2012-02-22T00:00:00-08:00</updated>
   <id>hhttp://fgnass.github.com/2012/02/22/mkay</id>
   <content type="html">&lt;p&gt;When I saw a project called Jade for jQuery being featured on DailyJS yesterday I thought I should take the time and promote my lightweight Jade/HAML-style DOM builder I wrote some month ago.&lt;/p&gt;

&lt;p&gt;In his &lt;a href=&quot;http://dailyjs.com/2012/02/21/jquery-roundup/&quot;&gt;jQuery Roundup&lt;/a&gt; Alex Young writes about jQuery and Jade:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Seeing as both of these technologies are all about CSS selectors, I’ve always felt like it makes sense to use them together.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I agree that using CSS selectors not only to &lt;em&gt;query&lt;/em&gt; but also to &lt;em&gt;create&lt;/em&gt; elements makes a lot of sense. But using a rather huge templating library like Jade on the client feels just wrong.&lt;/p&gt;

&lt;p&gt;What I wanted instead was a jQuery-flavored wrapper around the native DOM API that made it easy to create DOM trees leveraging CSS selectors the same way Jade and HAML do.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://nmjenkins.com/&quot;&gt;Neil Jenkins&lt;/a&gt; makes &lt;a href=&quot;http://blog.fastmail.fm/2012/02/20/building-the-new-ajax-mail-ui-part-2-better-than-templates-building-highly-dynamic-web-pages/&quot;&gt;some excellent points&lt;/a&gt; why using the DOM instead of templates is a good idea:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;No need to query the DOM, as you can just save references to nodes you’ll need later as you create them&lt;/li&gt;

&lt;li&gt;No escaping worries; zero chance of XSS bugs&lt;/li&gt;

&lt;li&gt;JSHint will validate your syntax&lt;/li&gt;

&lt;li&gt;Flexibility to use the full power of JS; easily call other functions to generate parts of your DOM tree&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;He has also written a &lt;a href=&quot;http://jsperf.com/innerhtml-or-dom/4&quot;&gt;JsPerf test&lt;/a&gt; that shows that using the DOM API is up to 50% faster than using innerHTML in modern browsers.&lt;/p&gt;

&lt;h2 id=&quot;lets_build_some_elements_mkay&quot;&gt;Let’s build some elements m’kay&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/fgnass/mkay&quot;&gt;M’kay&lt;/a&gt; is a tiny (556 bytes) plugin for jQuery or Zepto.js. You can use it like this:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;var&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;items&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;s1&#39;&gt;&amp;#39;Click on one of these&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;split&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39; &amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;);&lt;/span&gt;

&lt;span class=&#39;nx&#39;&gt;$&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39;body&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;).&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;mk&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39;#message&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;)&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;mk&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39;a.big&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;s2&#39;&gt;&amp;quot;M&amp;#39;kay on GitHub&amp;quot;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;).&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;attr&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39;href&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;s1&#39;&gt;&amp;#39;https://github.com/fgnass/mkay&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;).&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;_&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;mk&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39;ul&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;$&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;map&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;items&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;text&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;)&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
      &lt;span class=&#39;k&#39;&gt;return&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;$&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;mk&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39;li.item&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;text&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;).&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;click&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
        &lt;span class=&#39;nx&#39;&gt;alert&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;text&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;);&lt;/span&gt;
      &lt;span class=&#39;p&#39;&gt;});&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}));&lt;/span&gt;&lt;span class=&#39;err&#39;&gt;​&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will generate the following HTML and add a click listener to each item:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;html&#39;&gt;&lt;span class=&#39;nt&#39;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&#39;na&#39;&gt;id=&lt;/span&gt;&lt;span class=&#39;s&#39;&gt;&amp;quot;message&amp;quot;&lt;/span&gt;&lt;span class=&#39;nt&#39;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&#39;nt&#39;&gt;&amp;lt;a&lt;/span&gt; &lt;span class=&#39;na&#39;&gt;class=&lt;/span&gt;&lt;span class=&#39;s&#39;&gt;&amp;quot;big&amp;quot;&lt;/span&gt; &lt;span class=&#39;na&#39;&gt;href=&lt;/span&gt;&lt;span class=&#39;s&#39;&gt;&amp;quot;https://github.com/fgnass/mkay&amp;quot;&lt;/span&gt;&lt;span class=&#39;nt&#39;&gt;&amp;gt;&lt;/span&gt;M&amp;#39;kay on GitHub&lt;span class=&#39;nt&#39;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
  &lt;span class=&#39;nt&#39;&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
    &lt;span class=&#39;nt&#39;&gt;&amp;lt;li&lt;/span&gt; &lt;span class=&#39;na&#39;&gt;class=&lt;/span&gt;&lt;span class=&#39;s&#39;&gt;&amp;quot;item&amp;quot;&lt;/span&gt;&lt;span class=&#39;nt&#39;&gt;&amp;gt;&lt;/span&gt;Click&lt;span class=&#39;nt&#39;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class=&#39;nt&#39;&gt;&amp;lt;li&lt;/span&gt; &lt;span class=&#39;na&#39;&gt;class=&lt;/span&gt;&lt;span class=&#39;s&#39;&gt;&amp;quot;item&amp;quot;&lt;/span&gt;&lt;span class=&#39;nt&#39;&gt;&amp;gt;&lt;/span&gt;on&lt;span class=&#39;nt&#39;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class=&#39;nt&#39;&gt;&amp;lt;li&lt;/span&gt; &lt;span class=&#39;na&#39;&gt;class=&lt;/span&gt;&lt;span class=&#39;s&#39;&gt;&amp;quot;item&amp;quot;&lt;/span&gt;&lt;span class=&#39;nt&#39;&gt;&amp;gt;&lt;/span&gt;one&lt;span class=&#39;nt&#39;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class=&#39;nt&#39;&gt;&amp;lt;li&lt;/span&gt; &lt;span class=&#39;na&#39;&gt;class=&lt;/span&gt;&lt;span class=&#39;s&#39;&gt;&amp;quot;item&amp;quot;&lt;/span&gt;&lt;span class=&#39;nt&#39;&gt;&amp;gt;&lt;/span&gt;of&lt;span class=&#39;nt&#39;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class=&#39;nt&#39;&gt;&amp;lt;li&lt;/span&gt; &lt;span class=&#39;na&#39;&gt;class=&lt;/span&gt;&lt;span class=&#39;s&#39;&gt;&amp;quot;item&amp;quot;&lt;/span&gt;&lt;span class=&#39;nt&#39;&gt;&amp;gt;&lt;/span&gt;these&lt;span class=&#39;nt&#39;&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class=&#39;nt&#39;&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class=&#39;nt&#39;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can play with the example above &lt;a href=&quot;http://jsfiddle.net/fgnass/DyW7D/&quot;&gt;here on JsFiddle&lt;/a&gt;. For sources, tests and documentation please refer to the GitHub &lt;a href=&quot;https://github.com/fgnass/mkay&quot;&gt;project page&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Inheritance In Node</title>
   <link href="http://fgnass.github.com/2012/02/16/inheritance-in-node.html"/>
   <updated>2012-02-16T00:00:00-08:00</updated>
   <id>hhttp://fgnass.github.com/2012/02/16/inheritance-in-node</id>
   <content type="html">&lt;p&gt;I usually try to avoid using inheritance in JavaScript altogether but sometimes there are situations where using a classic OO-style can make things easier.&lt;/p&gt;

&lt;p&gt;Let’s assume we have a class &lt;code&gt;Foo&lt;/code&gt; which we want to extend:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;c1&#39;&gt;// constructor code&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;bar&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;c1&#39;&gt;// do something&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A common pattern is this:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;nb&#39;&gt;Object&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;create&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;);&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;bar&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;c1&#39;&gt;// do something else&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In contrast to the original definition of &lt;code&gt;Foo&lt;/code&gt; this code looks quite noisy.&lt;/p&gt;

&lt;h2 id=&quot;using_utilinherits&quot;&gt;Using util.inherits()&lt;/h2&gt;

&lt;p&gt;In Node.js there’s the &lt;a href=&quot;https://github.com/joyent/node/blob/master/lib/util.js#L498&quot;&gt;util.inherits()&lt;/a&gt; function which helps us to write the same thing a little more compact and also creates a &lt;code&gt;constructor&lt;/code&gt; property as well as a reference to the super constructor:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;util&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;inherits&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;);&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;bar&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;c1&#39;&gt;// do something else&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;};&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;baz&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;c1&#39;&gt;// yet another method&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;passing_properties_to_objectcreate&quot;&gt;Passing properties to Object.create()&lt;/h2&gt;

&lt;p&gt;Still we have to repeat &lt;code&gt;Bar.prototype&lt;/code&gt; for each property we want to add. We can overcome this by passing a property descriptor to &lt;code&gt;Object.create()&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;nb&#39;&gt;Object&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;create&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;bar&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;c1&#39;&gt;// do something else&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}},&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;baz&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;c1&#39;&gt;// yet another method&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}}&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Unfortunately this still looks quite noisy as we have to wrap all our properties into descriptor objects. On the other hand this syntax makes it easy to define getters or setters:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;nb&#39;&gt;Object&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;create&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;bar&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;c1&#39;&gt;// do something else&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}},&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;boo&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;nx&#39;&gt;get&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
      &lt;span class=&#39;k&#39;&gt;return&lt;/span&gt; &lt;span class=&#39;k&#39;&gt;this&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;_boo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;;&lt;/span&gt;
    &lt;span class=&#39;p&#39;&gt;},&lt;/span&gt;
    &lt;span class=&#39;nx&#39;&gt;set&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;)&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
      &lt;span class=&#39;k&#39;&gt;this&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;_boo&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;+&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;).&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;toUpperCase&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;();&lt;/span&gt;
    &lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Otherwise we’d have to call &lt;code&gt;Object.defineProperty(&amp;#39;boo&amp;#39;, {...})&lt;/code&gt; instead.&lt;/p&gt;

&lt;h2 id=&quot;the_get_and_set_operators&quot;&gt;The get and set operators&lt;/h2&gt;

&lt;p&gt;Still this isn’t as concise as it could be. Since JavaScript 1.8.5 the language supports the &lt;a href=&quot;https://developer.mozilla.org/en/JavaScript/Reference/Operators/get&quot;&gt;get&lt;/a&gt; and &lt;a href=&quot;https://developer.mozilla.org/en/JavaScript/Reference/Operators/set&quot;&gt;set&lt;/a&gt; operators which can be used inside an object literal to define getters and setters:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;c1&#39;&gt;// constructor code&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;get&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;boo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;k&#39;&gt;return&lt;/span&gt; &lt;span class=&#39;k&#39;&gt;this&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;_boo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;;&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;},&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;set&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;boo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;)&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;k&#39;&gt;this&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;_boo&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;s1&#39;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;+&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;).&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;toUpperCase&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;();&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now this is nice, but how can we use this approach for our subclass?&lt;/p&gt;

&lt;h2 id=&quot;the_deprecated_nonstandard_way&quot;&gt;The deprecated, non-standard way&lt;/h2&gt;

&lt;p&gt;One possibility is to use the non-standard &lt;code&gt;__proto__&lt;/code&gt; &lt;a href=&quot;https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/Proto&quot;&gt;property&lt;/a&gt; that allows us to change an objects prototype even after it has been created:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;__proto__&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;get&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;boo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;k&#39;&gt;return&lt;/span&gt; &lt;span class=&#39;s1&#39;&gt;&amp;#39;Buh!&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;;&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;a_standard_based_solution&quot;&gt;A standard based solution&lt;/h2&gt;

&lt;p&gt;Despite being deprecated the solution above is currently my favorite inheritance style. If you want to avoid using &lt;code&gt;__proto__&lt;/code&gt; for some reason you can write a helper function similar to Node’s &lt;code&gt;util.inherits()&lt;/code&gt; that uses standard ECMAScript 5 features to achieve similar results:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;c1&#39;&gt;// constructor code&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;bar&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;c1&#39;&gt;// do something&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;};&lt;/span&gt;

&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;c1&#39;&gt;// constructor code&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;nx&#39;&gt;util&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;Bar&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;Foo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;get&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;boo&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;()&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;k&#39;&gt;return&lt;/span&gt; &lt;span class=&#39;s1&#39;&gt;&amp;#39;Buh!&amp;#39;&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;;&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here is the implementation of the &lt;code&gt;util.prototype&lt;/code&gt; function:&lt;/p&gt;
&lt;div class=&#39;highlight&#39;&gt;&lt;pre&gt;&lt;code class=&#39;js&#39;&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;ctor&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;superCtor&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;proto&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;)&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
  &lt;span class=&#39;kd&#39;&gt;var&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;props&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;nx&#39;&gt;constructor&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;value&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;ctor&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;writable&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kc&#39;&gt;true&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;configurable&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;:&lt;/span&gt; &lt;span class=&#39;kc&#39;&gt;true&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;};&lt;/span&gt;
  &lt;span class=&#39;nb&#39;&gt;Object&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;getOwnPropertyNames&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;proto&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;).&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;forEach&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;kd&#39;&gt;function&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;name&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;)&lt;/span&gt; &lt;span class=&#39;p&#39;&gt;{&lt;/span&gt;
    &lt;span class=&#39;nx&#39;&gt;props&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;[&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;name&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;]&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;nb&#39;&gt;Object&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;getOwnPropertyDescriptor&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;proto&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;name&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;);&lt;/span&gt;
  &lt;span class=&#39;p&#39;&gt;});&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;ctor&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;nb&#39;&gt;Object&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;create&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;superCtor&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;prototype&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;,&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;props&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;);&lt;/span&gt;
  &lt;span class=&#39;nx&#39;&gt;ctor&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;.&lt;/span&gt;&lt;span class=&#39;nx&#39;&gt;super_&lt;/span&gt; &lt;span class=&#39;o&#39;&gt;=&lt;/span&gt; &lt;span class=&#39;nx&#39;&gt;superCtor&lt;/span&gt;&lt;span class=&#39;p&#39;&gt;;&lt;/span&gt;
&lt;span class=&#39;p&#39;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;tldr&quot;&gt;TL;DR&lt;/h2&gt;

&lt;p&gt;The &lt;a href=&quot;#the_get_and_set_operators&quot;&gt;get/set&lt;/a&gt; operators are cool and &lt;code&gt;__proto__&lt;/code&gt; &lt;a href=&quot;#the_deprecated_nonstandard_way&quot;&gt;is your friend&lt;/a&gt;. If you don’t want to use it you can write a simple &lt;a href=&quot;#a_standard_based_solution&quot;&gt;helper function&lt;/a&gt; to achive a similar result using standard ECMAScript features.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Brand New Blog</title>
   <link href="http://fgnass.github.com/2012/02/15/brand-new-blog.html"/>
   <updated>2012-02-15T00:00:00-08:00</updated>
   <id>hhttp://fgnass.github.com/2012/02/15/brand-new-blog</id>
   <content type="html">&lt;p&gt;Today I decided to abandon my Posterous blog and move over to GitHub Pages. The reason I chose Posterous in the first place was its &lt;a href=&quot;http://posterous.uservoice.com/knowledgebase/articles/36531-getting-started-with-markdown&quot;&gt;Markdown support&lt;/a&gt; and built-in syntax highlighting. Unfortunately both features are quite cumbersome. When I wrote my last post, the syntax highlighting just didn’t work anymore. While searching for a solution I came across &lt;a href=&quot;https://plus.google.com/116059998563577101552/posts/ehd9CLM9XKQ&quot;&gt;Paul Kinlan’s post&lt;/a&gt; which inspired me to try something completely different instead.&lt;/p&gt;

&lt;p&gt;After a brief look at &lt;a href=&quot;http://calepin.co/&quot;&gt;calepin.co&lt;/a&gt; and &lt;a href=&quot;http://scriptogr.am/&quot;&gt;scriptogr.am&lt;/a&gt; I decided give &lt;a href=&quot;http://jekyllbootstrap.com/&quot;&gt;jekyllbootstrap&lt;/a&gt; a try. It was interesting to see how much one could squeeze out of a bunch of &lt;a href=&quot;http://liquidmarkup.org/&quot;&gt;Liquid&lt;/a&gt; templates and a &lt;a href=&quot;https://github.com/plusjade/jekyll-bootstrap/blob/master/Rakefile&quot;&gt;Rakefile&lt;/a&gt; but like most bootstrap projects this felt a little bit bloated.&lt;/p&gt;

&lt;h2 id=&quot;kiss&quot;&gt;KISS&lt;/h2&gt;

&lt;p&gt;I decided to keep it simple instead and started from scratch. Since everything I blog about is usually related to a GitHub project in some way, I wanted a theme that resembled the look and feel of a GitHub project page with the same formatting as a project’s README. Especially code snippets should look exactly the same.&lt;/p&gt;

&lt;p&gt;I stole some design elements from the &lt;a href=&quot;https://github.com/blog&quot;&gt;official GitHub blog&lt;/a&gt; and made the layout responsive, so that you get a nice one-column view on mobile devices.&lt;/p&gt;

&lt;p&gt;Another great thing about GitHub pages is that you get a decent web-based editor for free as well as a version history of your posts and the possibility to work collaboratively.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2012-02-15-screenshot.jpg&quot; alt=&quot;Screenshot&quot; /&gt;&lt;/p&gt;</content>
 </entry>
 

</feed>
