The fastest way to try JavaScript is with a REPL like Node.js or a browser console. Open any page in your preferred web browser, then hit F12. Click on the Console tab and click on the prompt (marked by a blue > character). You can type JavaScript code in this field, and when you hit enter, it will be evaluated. Try typing some basic expressions.
> 2 + 2 // type this in...
// 4 the console will spit this back out
true || false;
// true
2 + 2 == 4
// true
console.log('hello world');
// hello world
// undefinedThe semicolon statement terminator is optional in most all places in JS.
Alternatively, you can write a .js file and execute it if you have Node.js installed.
// example.js
console.log('hello world')$ node example.jsAlternatively, these services let you build virtual webpages to show off code or test something small.
Destroy All Software famously made fun of JavaScript in a talk.
[] + [] // ''
{} + [] // 0
[] + {} // '[object Object]'The strangeness continues with examples like >=.
0 > null // false
0 == null // false
0 >= null // trueWhen in doubt, you can always find official specification of abstract behaviors. For abstract behaviors, look at the ECMA spec.
==http://www.ecma-international.org/ecma-262/5.1/#sec-11.8.4>=http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3
Understanding how the language is interpreted is a vital part of avoiding frustrations.