🟨 JavaScript Basics

JavaScript Basics: A Beginner's Guide for Absolute Newcomers

By The CodeCraft Team··10 min read
JavaScript code on a dark editor background

JavaScript runs in every browser on Earth and powers everything from interactive buttons to entire web apps. This guide walks you through the absolute basics — enough to start building.

Variables: let, const, var

const name = "Ada";   // can't be reassigned
let age = 30;          // can change
// avoid var in modern code

Data types

  • String — "hello"
  • Number — 42
  • Boolean — true / false
  • Array — [1, 2, 3]
  • Object — { name: "Ada" }
  • null and undefined

Functions

function greet(name) {
  return `Hello, ${name}!`;
}

const greetArrow = (name) => `Hello, ${name}!`;

Conditionals and loops

if (age >= 18) console.log("adult");

for (const n of [1, 2, 3]) console.log(n);

Run JavaScript right now

Open your browser, press F12, click Console, and start typing. No setup needed.

Frequently asked questions

Do I need to learn HTML and CSS first?

Yes — JavaScript manipulates HTML and CSS, so a basic grasp of both helps a lot.

Is JavaScript the same as Java?

No — completely different languages. Only the names are similar (a 1990s marketing decision).

Enjoyed this article?

Share it with a fellow developer or explore more tutorials in our blog.

More articles

Related articles