JavaScript Basics
This page teaches you the basics of JavaScript, for beginners, in 30 minutes.
This tutorial teachs the ES2015 version of JavaScript.
ES2015 is a new JavaScript spec released in 2015, and is supported by all browsers now. It adds significant features to the language.
Running JavaScript
Comment
Printing
String
Semicolon can be omitted most of the time. When to insert semicolon is complex. For now, just follow examples in this tutorial. For detail, see Semicolon Rules.
Arithmetic
Assignment
Number
JavaScript doesn't have int/float distinction. They are just type “number”. It's similar to other language's “float”.
console.log(typeof 3 === "number"); console.log(typeof 3.2 === "number"); // true
Convert Decimal to Integer
to convert a number to integer.
console.log(Math.floor(3.5847) === 3); console.log(Math.ceil(3.5847) === 4); console.log(Math.round(3.54) === 4); console.log(Math.round(3.55) === 4);