Playing Around with Closures

I've had the opportunity to join in the interview process to assess Front End Developer candidates, and I've always thought it'd be fun to ask interviewees (especially ones who claim proficiency in Javascript) if they can write a simple example illustrating a closure.

Since I was awake for baby-duty I decided to CodePen the exercise myself, along with some work-arounds using IIFE, .bind(), and let

And if you're scheduled for an interview and are all excited that you've found this 'leaked' information, I'm sorry to dash your hopes. I'm not in the driver's seat running the interviews so this isn't actually in the interview process.

Nevertheless, play around with closures. I'm sure you'll enjoy the learning process anyways!

See the Pen Playing with Closures by Duncan (@duncanleung) on CodePen.

Duncan Leung

Front End Developer at iHerb.com

Irvine, CA

Subscribe to Duncan Leung: Javascript and Front End Development

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!