This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* --- No repetition if key: value is identical --- */ | |
// ES5 | |
var es5_getLaptopProperties = function(make, model, year) { | |
return { | |
make: make, | |
model: model, | |
year: year | |
} | |
} | |
es5_getLaptopProperties("Apple", "MacBook", "2015"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 - variant 1 | |
var es5_Person = function (firstname, lastname) { | |
this.firstname = firstname; | |
this.lastname = lastname; | |
this.greet = function () { | |
console.log('Hello I am ' + this.firstname + ' ' + this.lastname); | |
} | |
} | |
var es5_john = new es5_Person('John', 'Doe'); | |
es5_john.greet(); // outputs: Hello my name is John Doe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rest Parameter | |
const restParameter = (firstname, lastname, ...adress) => { | |
console.log('firstname: ', firstname); | |
console.log('lastname: ', lastname); | |
console.log('adress: ', adress); | |
} | |
restParameter('John', 'Doe', 'Example Street 1', '12345', 'Exampletown'); | |
// outputs: | |
// firstname: John | |
// lastname: Doe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getJoke() { | |
let url = 'https://api.icndb.com/jokes/random'; | |
let result = await (await fetch(url)).json(); | |
return result; | |
} | |
async function initApiCall() { | |
try { | |
let data = await getJoke(); | |
console.log(data.value.joke) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// callback | |
function callback() { | |
setTimeout(function () { | |
console.log('1. First thing setting up second thing'); | |
setTimeout(function () { | |
console.log('2. Second thing setting up third thing'); | |
setTimeout(function () { | |
console.log('3. Third thing setting up fourth thing'); | |
setTimeout(function () { | |
console.log('4. Fourth thing setting up fifth thing'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- window.html --> | |
<!DOCTYPE html> | |
<html lang="de"> | |
<head> | |
<meta charset="utf-8"> | |
<title>window</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- window.html --> | |
<!DOCTYPE html> | |
<html lang="de"> | |
<head> | |
<meta charset="utf-8"> | |
<title>window</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fadeOut = (el, smooth = true, displayStyle = 'none') => { | |
if (smooth) { | |
let opacity = el.style.opacity; | |
let request; | |
const animation = () => { | |
el.style.opacity = opacity -= 0.04; | |
if (opacity <= 0) { | |
opacity = 0; | |
el.style.display = displayStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fadeIn = (el, smooth = true, displayStyle = 'block') => { | |
el.style.opacity = 0; | |
el.style.display = displayStyle; | |
if (smooth) { | |
let opacity = 0; | |
let request; | |
const animation = () => { | |
el.style.opacity = opacity += 0.04; | |
if (opacity >= 1) { |