Skip to content

Instantly share code, notes, and snippets.

@omniosi
Created August 1, 2013 23:03
Show Gist options
  • Save omniosi/6136121 to your computer and use it in GitHub Desktop.
Save omniosi/6136121 to your computer and use it in GitHub Desktop.
explaining how to lock your variables and functions to this code alone to make sure there is no interference with other code on the page or site.
<!DOCTYPE html>
<html>
<head>
<title>Name spacing</title>
</head>
<body>
<script type="text/javascript">
var namespace = {
firstname: 'Ornette',
lastname: 'Coleman',
doSomething:function(){
//add code here
}
}
console.log('Your name is '+namespace.firstname+' '+namespace.lastname+'.');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment