Closure: It’s not a complex concept. Yet it’s hard to describe. Sure, a lot of programming jargon is abstract and requires a little bending of one’s mind. Polymorphism, reflection, encapsulation — hell, even abstraction is an abstract concept.

In my own effort to understand closures better, I’ve compiled the best descriptions of JavaScript closures from authoritative sources on the Web. Hopefully this will be useful to you, too.

Image for post
Image for post
Not the closure I’m talking about.

Mozilla’s docs describe closures like so:

Closures are functions that refer to independent (free) variables (variables that are used locally, but defined in an enclosing scope). …


[tl;dr — Use ActiveSupport::Concern with modules in your Rails tests to reuse behavior. Or read the longer discussion and learn more about what’s going on behind the scenes.]

After writing a lot of BDD tests using Rspec and Cucumber in my Rails projects, I decided on a new approach for a new project: use the default Rails 4 test framework, Minitest. Duh.

Some consider Minitest “less readable.” I don’t really agree, and despite a lot of nice features, there’s something to be said for writing plain old Ruby vs. learning and remembering DSLs for both Rspec and Cucumber.

Committed to…


While studying up on the 2014 Formula One season, I spent a little time creating an animated GIF of Ferrari’s car over the last eight iterations. Interesting to watch the change of specific areas, like the front end and the rear wing. The images are centered on the driver’s position and are lined up as best as possible to be consistent with where the ground would be.

Evolution of the Ferrari F1 as animated GIF
Evolution of the Ferrari F1 as animated GIF

(Thanks to these guys for the images.)


Yeah, you wish this was about beer.

So you’re using some trick Web fonts for your site or app. It looks awesome in development. Yay.

Old Coors can
Old Coors can

You push to production, where your assets are all hosted on a CDN and suddenly your fonts stop working on Firefox and probably Internet Explorer (9+), too. You see crappy little squares where awesome fonts should be.

Bang. You’ve just run into the browsers’ same-origin policy restrictions.

I experienced this problem on Schock.net, where my assets are hosted on Amazon S3 with Cloudfront as the CDN. …


JSONP is a way to fetch JSON data from a different domain, often in an asynchronous way, but without being restricted by the browser’s same-origin policy like you would be with XMLHttpRequest. But perhaps you only know it via a library like jQuery, which auto-magically handles JSONP URLs. Here's a simple JSONP example and breakdown to show what's really going on behind the scenes.

I was recently quizzed on JSONP and how it works, and my response was something like, mumble … mumble … callback … mumble … use other dudes’ JSON.


Have a loose or wobbly Macbook Pro screen?
Have a loose or wobbly Macbook Pro screen?

My 2008 unibody Macbook Pro has a loose screen. Loose and wobbly and drunken at times. It’s been chugging along loyally for over three years, and in Internet time, it’s like a Regis Philbin. But as we all know, old folks can get wobbly. No shame in that — but it happens.

The whole screen/monitor (the part that flips up) developed about 2 cm of back-and-forth play, and it felt like perhaps the hinge was loose. Still usable, but definitely putting a dent in my Macbook’s sexy. …


[Jason’s note: Three Days in Hell.A. is the account of two college journalists — David Downs (writer) and myself (photographer) — and our experience at the 2000 Democratic National Convention in Los Angeles, CA. It was originally published in August 2000 on jasonschock.com. The original story is preserved at the Internet Archive.]

Cops secure the intersection of Figueroa and Olympic in downtown Los Angeles after a anti-police brutality march got slightly out of hand.
Cops secure the intersection of Figueroa and Olympic in downtown Los Angeles after a anti-police brutality march got slightly out of hand.

Jason Schock

Web developer and UX guy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store