January 31st 2018
Hello! I am really excited because I have started a new course by Wes Bos, ES6 for Beginners. I have already come across ES6 in previous courses and I think it is of key importance. Today we covered the new variable let and const. Before we had var variables. Vars can be updated and redefined, and they can be function as well as global scoped. However let and const are scoped to the block statement, which are within the open and closed curly braces. The difference between const and let is that the const variable cannot be updated, let can. The properties of the const variable can change though.
for (let i = 0; i < 10; i++) {
setTimeout(function() {
console.log('The number is ' + i);
}, 1000);
}
If in this case we had var instead of let, it would only console log it once.
At the CSS grid I just revised today.
And at the Web development Bootcamp I practiced events, mouseover and mouseout to be precise. We made a sample todo list where hovering over an element highlights it and you can cross it out by clicking it.
for (var i = 0; i<lis.length; i++) {
lis[i].addEventListener("mouseover", function(){
this.classList.add("selected");
Here is another example of the famed “this”. In this case “this” refers to the elemnt or item the event was triggered on. The for loop loops over the list elements and checks if the mouseover event happened, if yes it will run the functions which is adding a class of selected. The selected class was defined in the css.
Cheers.