Logo LIBR
Halo

Portfolio

Back to Blog
6 min read
JS Module 1Jun 2026

JavaScript Basics: Your First Step Into the Logic World

JavaScript, Front-End, Logic
Syifa Fauziyah Arizal

If HTML is the skeleton and CSS is the outfit, JavaScript is the brain. Without it, your website is just a pretty statue doing absolutely nothing.

No JavaScript? Congrats, you built a digital brochure. JavaScript is what turns a static page into something users can interact with, click, type into, and actually use.

What is JavaScript?

JavaScript is the programming language that makes your website alive. Button clicks, animations, form validation, fetching data from APIs — yeah, that's all JavaScript doing overtime.

Why JavaScript Matters

  • Runs directly in the browser (client-side)
  • Makes websites interactive
  • Dynamic and flexible
  • Mandatory skill for front-end developers

Without JavaScript, your website is static, silent, and kinda sad.

How to Run JavaScript

There are three ways to use JavaScript in HTML:

1. Inline JavaScript

HTML
<button onclick="alert('Hello!')">Click me</button>

Only okay for demos. Not for real projects.

2. Internal JavaScript

HTML
<script>
  console.log("Hello from internal JS!");
</script>

3. External JavaScript (Best Practice)

HTML
<script src="script.js"></script>

Clean, scalable, and future-you will thank you.

Meet Your Best Friend: console.log()

Your browser has a developer console. This is where JavaScript talks to you.

JavaScript
console.log("Testing... 1 2 3");
  • Debug errors
  • Check variable values
  • Understand program flow
  • Question your life choices

Variables — Where Data Lives

Modern JavaScript uses only two keywords:

  • let → value can change
  • const → value stays forever
JavaScript
let age = 20;
const name = "Syfa";

age = 21;      // valid
name = "Budi"; // error 🚫

Forget var. That era is over.

JavaScript Data Types

TypeExample
String"Hello"
Number24, 3.14
Booleantrue / false
Nullnull
Undefinedundefined
Object{ name: "Syfa" }

Basic Operators

JavaScript
let a = 10;
let b = 3;

console.log(a + b);
console.log(a - b);
console.log(a * b);
console.log(a / b);
console.log(a % b);

Simple math now, serious logic later.

Your First Mini Program

JavaScript
let name = "Syfa";
let age = 20;

console.log(`Hello ${name}, you are ${age} years old`);

Template literals = clean, modern, and actually readable.

Key Takeaways

  • JavaScript is the brain of the web
  • Know how to connect JS to HTML
  • console.log() is your debugging weapon
  • Use let and const
  • Understand data types before touching logic

More to read