Variables

javascript
let name = "Knobly";      // can change
const PI = 3.14;          // constant
var old = "avoid using";  // old style

Functions

javascript
// Regular
function greet(name) {
  return "Hello, " + name;
}

// Arrow
const add = (a, b) => a + b;

console.log(greet("World"));
console.log(add(2, 3));

DOM Manipulation

javascript
// Select elements
const el = document.getElementById("myId");
const els = document.querySelectorAll(".card");

// Modify
el.textContent = "New text";
el.style.color = "blue";
el.classList.add("active");

// Events
el.addEventListener("click", () => {
  alert("Clicked!");
});

ES6+ Features

javascript
// Template literals
const msg = `Hello ${name}, you are ${age} years old`;

// Destructuring
const { x, y } = { x: 10, y: 20 };
const [first, ...rest] = [1, 2, 3, 4];

// Spread operator
const merged = { ...obj1, ...obj2 };

// Optional chaining
const value = user?.profile?.name;
Hi! 👋
KnoblyAI
Online

Hello! 👋

Your futuristic AI learning companion

KnoblyAI can make mistakes. Double-check important replies.