1.js-basics.md
Quiz
~/ hackweb.dev
...
~/
/tutorials
/en/js/js-basics/edit
~ Contribute
Suggest a correction or improvement. The author reviews it before it goes live.
Loading...
en/tutorials/js/1js-basics
# JavaScript Basics JavaScript brings your pages to life. It runs in the browser and can change anything on the page after it loads. ## Variables with let and const Variables store values. Use `const` for values that never change and `let` for ones that do. ```js const title = "hackweb.dev"; let score = 0; score = score + 10; console.log(title, score); ``` ## Values and types JavaScript has a few core types — numbers, strings, booleans, and more. ```js const age = 25; // number const name = "Ada"; // string const isAdmin = true; // boolean console.log(typeof age, typeof name, typeof isAdmin); ``` ## Strings Strings are text. Join them with `+` or with template literals. ```js const first = "Ada"; const last = "Lovelace"; const full = `${first} ${last}`; console.log(full); ``` ## console.log `console.log` prints values to the console — your best debugging friend. ```js console.log("hello from the console"); ``` ## The event loop JavaScript handles one thing at a time, but things like timers happen in the background. The **event loop** is how they come back. Watch it in action: ```animation name="event-loop" ```
Submit suggestion
cancel