Posted By

chrisaiv on 11/27/14


Tagged

javascript


Versions (?)

Proper Global Variables


 / Published in: JavaScript
 

URL: http://lib-rails.usc.edu:5555/javascripts/edu.usc.Globals.js

It's not a good idea to create global variables unless you do something like this. From here, all you need to do is setData(YOUR_DATA) and getData()['key']

  1. //Type: Object.
  2. function setData( d ) {
  3. var data = d;
  4. getData = function() {
  5. return data;
  6. }
  7. }
  8.  
  9. //Type: String.
  10. function setSection( d ){
  11. var data = d;
  12. getSection = function(){
  13. return data;
  14. }
  15. }

Report this snippet  

You need to login to post a comment.