Created
April 6, 2019 16:56
-
-
Save boombang/9f256b47f3c6a4762dc20a144ba45f5c to your computer and use it in GitHub Desktop.
This file contains 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
//my-module.js | |
define([], function() { | |
var privateVar = "Ben Cherry"; | |
var publicVar = "Hey there!"; | |
function privateFunction() { | |
console.log( "Name:" + privateVar ); | |
} | |
function publicSetName( strName ) { | |
privateVar = strName; | |
} | |
function publicGetName() { | |
privateFunction(); | |
} | |
return { | |
setName: publicSetName, | |
greeting: publicVar, | |
getName: publicGetName | |
} | |
}); | |
// index.js | |
define(['my-module'], function (myModule) { | |
myModule.setName( "Paul Kinlan" ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment