Last active
February 1, 2021 20:27
-
-
Save Theo-denBlanken/22153c9f49ffe113dd3afe691e3f86a7 to your computer and use it in GitHub Desktop.
Demo om de arrow-notatie van functies in JavaScript te laten zien
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
// een gebruikelijke notatie | |
function schrijfInBody(string) { | |
let tekst; | |
if( string ) { // ga na of er een argument is meegegeven | |
tekst = string; | |
} else { | |
tekst = "Dit komt van de functie schrijfInBody"; | |
} | |
document.body.innerHTML = tekst; | |
} | |
// aan te roepen met schrijfInBody() of met schrijfInBody('Een mooie zin op de webpagina!') |
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
// hier dezelfde functionaliteit, maar met gebruikmaking van de arrow-functie-notatie | |
const schrijfInBodyArrow = (string) => { | |
let tekst; | |
if( string ) { | |
tekst = string; | |
} else { | |
tekst = "Dit komt van de functie schrijfInBodyArrow"; | |
} | |
document.body.innerHTML = tekst; | |
} | |
// aan te roepen met schrijfInBodyArrow() of met schrijfInBodyArrow('Een mooie zin op de webpagina!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment