Programming Fundamentals/Introduction/JavaScript
Appearance
hello.js
[edit | edit source]// This script displays "Hello world!"
//
// References:
// http://javascript.info/hello-world
// https://www.w3schools.com/js/js_output.asp
// http://progopedia.com/example/hello-world/114/
output("Hello world!")
function output(text) {
if (typeof document === 'object') {
document.write(text);
}
else if (typeof console === 'object') {
console.log(text);
}
else {
print(text);
}
}
Try It
[edit | edit source]Copy and paste the code above into one of the following free online development environments or use your own JavaScript compiler / interpreter / IDE.
- Chapman.edu: Online JavaScript Interpreter
- CodeChef
- GDB Online
- Ideone
- JS.do
- paiza.IO
- PythonTutor
- repl.it