Skip to content

Instantly share code, notes, and snippets.

@ssaunders
ssaunders / exposePriv.js
Created September 4, 2014 17:57
Expose private variables for unit testing in JavaScript
/* The code below takes a constructor and exposes its private functions
Useful for unit testing (not general use). An example usage is below it.
Access to the private functions available through the _privMems property. */
/* Original credit goes to Rob Gravelle
http://www.htmlgoodies.com/beyond/javascript/accessing-private-functions-in-javascript.html */
var Reflection = {};
Reflection.createExposedInstance = function(objectConstructor, args)
{