Created
October 4, 2018 12:48
-
-
Save mindbrave/8218a25de6a7ba1372a221e68fa27ac6 to your computer and use it in GitHub Desktop.
Why declarative > imperative. Simple example.
This file contains hidden or 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
| <html> | |
| <head> | |
| <title>Declarative!</title> | |
| </head> | |
| <body> | |
| <h1>Declarative!</h1> | |
| </body> | |
| </html> |
This file contains hidden or 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 html = document.createElement('html'); | |
| const head = document.createElement('head'); | |
| const title = document.createElement('title'); | |
| const body = document.createElement('body'); | |
| const h1 = document.createElement('h1'); | |
| const titleText = "Imperative!"; | |
| title.textContent = titleText; | |
| h1.appendChild(document.createTextNode(titleText)); | |
| head.appendChild(title); | |
| body.appendChild(h1); | |
| html.appendChild(head); | |
| html.appendChild(body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment