lecture 2
31-06-2016
Michael Trouw
Israel Menis
Dolemite - Scott Henderson
Who is here ?
1.
1.
:c
1h 30m
30m
One Style to Rule Them All
(sudo) npm install -g standard
Have you ever heard or done something with it ?
https://desktop.github.com/ (no linux client so far)
should be on (your) github
should conform to standardJs styleguide:
if you knowingly deviate from standardJs,
you have to be able to explain your reasoning.
What did I do ?
jQuery's $.ajax builds on XmlHttpRequest.
can be done using two ways (see this SO post):
The scope of a name binding – an association of a name to an entity, such as a variable – is the part of a computer program where the binding is valid: where the name can be used to refer to the entity
var width = 12; // width variable
var height = 'test'; // height variable
function calculateArea(width, height) {
try {
var area = width * height; // Try to calculate area
if (!isNaN(area)) { // If it is a number
return area; // Return the area
} else { // Otherwise throw an error
throw new Error('calculateArea() received invalid number');
}
} catch(e) { // If there was an error
console.log(e.name + ' ' + e.message); // Show error in console
return 'We were unable to calculate the area.'; // Show users a message
}
}
// TRY TO SHOW THE AREA ON THE PAGE
document.getElementById('area').innerHTML = calculateArea(width, height);Closures are functions INSIDE functions.
Yes, this is possible!
read: https://developer.mozilla.org/en/docs/Web/JavaScript/Closures
Palindromes