Morning:
Afternoon:
megaRoster.addChild calls this.buildListItem)this with .bindMaking your own copy of an existing repo is called forking. Unlike a cloned copy, which retains the permissions set by the original owner, a forked copy now belongs to you (meaning you can make any changes you want to it).
Just hit the ‘Fork’ button in the upper right of the repo page, and this will add a copy to your personal github.
Foundation is a CSS (and JS) framework that makes it easy to create stylish, responsive web pages. The foundation (get it?) of it is the grid system. The grid splits the page into 12 equally-sized columns, making it easy to set the alignment of elements on the page by specifying how many columns they span.
In addition, you can add sizes of ‘small’, ‘medium’, ‘large’, etc, to specify different behavior at different screen sizes. In the following example, the two child divs will be full screen width at small screen sizes (stacked on top of each other), and half of the screen width at medium and larger screen sizes (appearing next to each other).
<div class="row">
<div class="small-12 medium-6 columns">
</div>
<div class="small-12 medium-6 columns">
</div>
</div>
this with bindIn JavaScript, the value of this in any function depends on the context in which the method was called. For example, if a function is an event listener callback, this will be set to the target that caused the event to fire. Sometimes, this is not the this we want. Luckily, JavaScript also has the .bind method, which allows a function to be ‘bound’ to a particular value of this.
this.x = 9 // here, 'this' is the global window object
const module = {
x: 81,
getX: function() {
return this.x
}
}
module.getX() // 81
// getX was called on module, so 'this' is module and this.x is 81
const retrieveX = module.getX
retrieveX() // 9
// retrieveX is a const declared in the global scope, so 'this' is window
const boundGetX = retrieveX.bind(module)
boundGetX() // 81
// by binding to module, 'this' will always be set to module for boundGetX
JavaScript’s this is a source of consternation for many a developer, but it doesn’t have to be! Make the effort to learn it early in your career, and it will pay off in the long run. Here is a great article with lots of code examples that will help you get a grasp on the nuances of this. Let’s Settle ‘this’ - Part One | Part Two
Jeffervescence (morning) | Dinoplasty (afternoon)
These are links directly to the repo as of the commits where we left off today. Even after we add more commits tomorrow, these links will still point to this point in time.
window.localstorage. The flicks/dinosaurs should stay in the list even when the page is refreshed.