-
-
Save wozzup/b9bec7beb503cc3d9868 to your computer and use it in GitHub Desktop.
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
#Hello World Characters of Code Comparison | |
##JavaScript | |
[Preview](http://embed.plnkr.co/blHgfEJV8y2yQcWZKRqo/preview) | |
Characters: 700 | |
Lines of JavaScript: 13 | |
```html | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>Hello World with pure JavaScript</h1> | |
Write some text in textbox: | |
<input id="hello-input" type="text" /> | |
<h2 id="hello-output">Hello </h2> | |
<script> | |
var inputField = document.getElementById('hello-input'); | |
var label = document.getElementById('hello-output'); | |
var handleKeyup = function() { | |
var value = inputField.value; | |
label.innerHTML = 'Hello ' + value; | |
} | |
if (document.addEventListener) { | |
document.addEventListener('keyup', handleKeyup); | |
} else if (document.attachEvent) { | |
document.attachEvent('keyup', handleKeyup); | |
} | |
</script> | |
</body> | |
</html> | |
``` | |
##jQuery | |
[Preview](http://embed.plnkr.co/eZ4MQ77y8o8KVRnAhG4E/preview) | |
Characters: 529 | |
Lines of JavaScript: 7 | |
```html | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>Hello World with jQuery</h1> | |
Write some text in textbox: | |
<input id="hello-input" type="text" /> | |
<h2 id="hello-output">Hello </h2> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> | |
<script> | |
var inputField = $('#hello-input'); | |
var label = $('#hello-output'); | |
inputField.on('keyup', function() { | |
var value = inputField.val(); | |
label.html('Hello ' + value); | |
}); | |
</script> | |
</body> | |
</html> | |
``` | |
##AngularJS | |
[Preview](http://embed.plnkr.co/Kzc9OxJSJF7I9d3U4exK/preview) | |
Characters: 325 | |
Lines of JavaScript: **0** | |
```html | |
<!DOCTYPE html> | |
<html ng-app> | |
<body> | |
<h1>Hello World with AngularJS</h1> | |
Write some text in textbox: | |
<input type="text" ng-model="sometext" /> | |
<h2>Hello {{sometext}}</h2> | |
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> | |
</body> | |
</html> | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment