Last active
March 11, 2018 22:13
-
-
Save qpwo/94dc8278f38d3447cc6d8dc2e7a2d197 to your computer and use it in GitHub Desktop.
A minimal possible working example of a javascript library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var lukemath = new (function() { | |
| var privatePi = 3.14; | |
| this.tau = 2 * privatePi; | |
| var privateSquare = function(n) { | |
| return n * n; | |
| } | |
| this.fourth = function(n) { | |
| return privateSquare(privateSquare(n)); | |
| } | |
| })(); | |
| // > lukemath.tau | |
| // 6.28 | |
| // > lukemath.fourth | |
| // [Function] | |
| // > lukemath.fourth(5) | |
| // 625 | |
| // > lukemath.privatePi | |
| // undefined | |
| // > lukemath.privateSquare | |
| // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment