Nicholas Johnson

Engineer / Trainer / BSc AI

JavaScript is Lovely

JavaScript is the democratic language of the internet. It supports all coding styles and all skill levels. There's nothing else like it, it's a magnificent little language with a pure soul and a few wonky bits around the edge. It has grown with us over the years, imposing no restrictions and letting us discover new ways of working almost every day.

I was lucky enough to pick up JavaScript in 1997, when it was first coming out in Netscape. Back then it was a weird little beast that no one quite knew what to do with. I've been using ever since, and I like to think we've grown together.

Writings

  • JavaScript Conditionals for Programmers

    This short course assumes you’re already proficient in at least one language. In it, we focus on the tiny soul of JavaScript, a small set of rules, from which everything else logically follows.

    Most tutorials skip to the end, they tell you the magic words to type to make a blog or an app. This course doesn’t do that, instead we start with the half dozen principles on which the language is founded, and build up to the rest of it. There’s actually not very much to know, it’s a tidy little language.

    October 2023 · 1 min read

  • Passing additional props to React children with React.Children.map

    React components are supposed to be modular and stackable, just like html. We achieve nesting in React components by passing children as an implicit prop to our component, but what if we want to do more than simply dump those children on to the page? What if we want to manipulate them in some way? Enter React.Children.map

    September 2023 · 3 min read

  • Astro vs. Next vs. Eleventy

    A Static site generator is a piece of software that lets you write pages, ideally in Markdown, then press a button to create a nested folder full of HTML that you can drop onto any old hosting environment. Static sites are fast, just HTML and CSS. They are trivial to make accessible, you actually don’t need any JavaScript at all.

    My criteria for selecting a static site generator were as follows…

    September 2023 · 5 min read

  • What is Babel, and how will it help you write JavaScript?

    Babel is a JavaScript transpiler that converts edge JavaScript into plain old ES5 JavaScript that can run in any browser (even the old ones).

    It makes available all the syntactical sugar that was added to JavaScript with ES6 and ES7, including classes, fat arrows, multiline strings, generators, and many more.

    You can convert prety much any modern JavaScript features into code that will run on any browser, even the really old ones. This is fantastic news if you need to support older browsers, mobile browsers, Safari, IE11, or anything other than edge Chrome.

    April 2016 · 5 min read

  • React Fundamentals For AngularJS Developers

    TL;DR: AngularJS is a complex, monolithic framework that makes lots of choices for you. React is a DOM manipulation library that fits into a dynamic evolving ecosystem. Both are actually rather good.

    April 2016 · 8 min read

  • How to do transclusion in Angular (ES5)

    March 2016 · 4 min read

  • How does the TypeScript Angular DI magic work?

    February 2016 · 6 min read

  • How to do Everything in Angular 2 using vanilla ES5 or ES6

    February 2016 · 4 min read

  • What's the difference between annotations and decorators in Angular?

    February 2016 · 5 min read

  • AngularJS vs. Angular

    AngularJS and Angular are philosophically different. Angular 1 is at heart a DOM compiler. We write HTML, and the Angular compiler takes care of compiling it into a web application. It was a tidy little thing, and very small.

    Over time Angular 1 was used to create larger and larger applications. We started arranging our code into components. We repurposed directives to make them serve as components, then used isolate scope to separate them one from another.

    Angular 2 is the logical endpoint of this transformation. It is no longer a DOM compiler. Instead, it’s an component driven architecture with batteries included.

    February 2016 · 2 min read

  • Creating Read-Only & Virtual Attributes with JavaScript Getters and Setters

    Getters and setters let us create read only attributes of JSON objects. They work in all current browsers (except IE8), so you can use them today.

    January 2016 · 2 min read

  • Why you should (sometimes) use MongoDB

    Mongo has taken some heavy flak, particularly from the SQL crowd. It’s missing a few features, has bugs, and does things in an unfamiliar way. If your data is tree shaped, you like JavaScript, and you can live without transactions, it might still be the right tool.

    July 2015 · 3 min read

  • How does ng-app work?

    Today’s Angular is the angularInit function: the thing that makes ng-app work. It selects elements, discovers the root module name, then shells out to bootstrap.

    June 2015 · 1 min read

  • Organising your AngularJS code with Browserify

    Organising JavaScript in a larger app becomes quite painful quite quickly. The issue is that order of inclusion matters. If I write a service that belongs to a module, I’d better make sure I have created my module before I try to append the service to it or my code will collapse in a messy heap. As we get more and more modules and more and more files, this becomes progressively harder.

    April 2015 · 6 min read

  • BackboneJS - Step by Logical Step

    Backbone is a the grand-daddy of all the JavaScript MVC frameworks. It’s the progenitor of frameworks like Ember, Angular, even Meteor. It’s a sensibly put together library full of tools to help you organise your web application, a toolkit for tidy JavaScript.

    June 2014 · 10 min read

  • The JQuery Book,

    JQuery is a library written in JavaScript which is primarily about DOM manipulation. It lets you find parts of a web page and make changes to them with very little code. It’s wildly popular and is used extensively across the Internet. It also forms the basis of other larger frameworks. If you’re serious about web development you need to know jQuery.

    June 2014 · 35 min read

  • MVC JavaScript without a Framework

    Looking at Rails or Angular there’s a tendency to think of MVC as something rather complicated and difficult to achieve, something that really demands a framework.

    In fact, MV* style JavaScript really is trivially easy to write. It’s a pattern I’ll often drop into if I need to make anything beyond the basics, but I don’t want to break out Angular’s big guns.

    In this post, we’ll create a simple MV pattern. We’ll build a Model and a View and wire these together using events.

    July 2013 · 3 min read

  • JavaScript Closure and Variable Scope

    3 min read

  • JavaScript Constructors, Classes and Prototypical Inheritance

    1 min read

  • 1 min read

  • How to run JavaScript code in a browser, or with Node

    3 min read

  • 1 min read

  • JavaScript Function Portability

    3 min read

  • 2 min read

  • JavaScript for Programmers

    1 min read

  • Welcome to the JavaScript for Programmers course!

    This short course assumes you’re already proficient in at least one language. In it, we focus on the tiny soul of JavaScript, a small set of rules, from which everything else logically follows.

    Most tutorials skip to the end, they tell you the magic words to type to make a blog or an app. This course doesn’t do that, instead we start with the half dozen principles on which the language is founded, and build up to the rest of it. There’s actually not very much to know, it’s a tidy little language.

    5 min read

  • JQuery for Programmers

    1 min read

  • How does This work in JavaScript?

    4 min read

  • JavaScript Numbers

    1 min read

  • JavaScript Closure and Variable Scope

    5 min read

  • 1 min read

  • How to run JavaScript code in a browser, or with Node

    2 min read

  • JavaScript Strings

    1 min read

  • JavaScript Variables and Scope with Let, Const and Var

    2 min read