Guest User

Javascript Nesting Hell

a guest
Apr 16th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. As in this example, App is a var which is function expression which contains init as var which is assigned a function expression with no name. After this I lose the focus. How do I even keep track of closing parenthesis and curly braces?
  3. And shouldn't the invocation be like:
  4. App.App().init()
  5.  
  6. */
  7.  
  8. var App = function App() {
  9. this.init = function() {
  10. var animals = ['cats', 'dogs', 'aardvarks', 'hamsters', 'squirrels'];
  11. var $list = $('#myList');
  12. animals.forEach(function(animal) {
  13. $list.append('<li>' + animal + '</li>');
  14. });
  15. };
  16. };
  17. var app = new App();
  18. app.init();
Add Comment
Please, Sign In to add comment