Let’s compare the most popular JavaScript frameworks by implementing the shortest “Hello, world!” app.
The goal is to write the shortest possible app that will display “Hello, world!” on the screen.
“Hello, world!” in React
HTML
<div id="root"></div>
React
ReactDOM.render(
Hello, world!
,
document.getElementById('root')
);
React version of the smallest “Hello, world!” is impressive. Now let’s see how it looks in Vue.js.
“Hello, world!” in Vue.js
HTML
<div id="app"><h1>{{ message }}</h1></div>
Vue.js
new Vue({
el: '#app',
data: {
message: 'Hello, world!'
}
})
If you know a shorter version or want to add another example please share it in the comments below.
Cheers,
Renat Galyamov
Want to share this with your friends?
👉renatello.com/shortest-hello-world-js-app
PS: Make sure you check other JavaScript tutorials, e.g. how to create an array of numbers in JavaScript, generate an array of years in JavaScript or Toggle class onclick in plain inline JavaScript.