Labs ICT
Pro Login

Style Guide

1 min read | JavaScript Tutorial

Want the full learning experience?

Get structured courses, certificates, projects, and instructor support with LabsICT Pro.

Explore Pro Courses

Naming Conventions

Use camelCase for variables and functions, PascalCase for classes, and UPPER_SNAKE_CASE for constants.

const MAX_ATTEMPTS = 5;

let userName = "Alice";
function getUserData() { }

class UserProfile { }

const isActive = true;
const totalPrice = 99.99;

Formatting & Indentation

Use 2 spaces for indentation. Keep lines under 80-100 characters. Place opening braces on the same line.

if (condition) {
  doSomething();
} else {
  doOther();
}

const items = ["apple", "banana", "cherry"];

function calculateTotal(items, taxRate) {
  const subtotal = items.reduce((sum, item) => sum + item.price, 0);
  return subtotal * (1 + taxRate);
}

Consistency Practices

Use const by default, let only when reassigning. Use semicolons. Prefer arrow functions for short callbacks.

const multiply = (a, b) => a * b;

const numbers = [1, 2, 3, 4];
const doubled = numbers.map(n => n * 2);

function process(data) {
  const result = [];
  for (const item of data) {
    if (item.isValid) {
      result.push(item);
    }
  }
  return result;
}