deepdev.org-100 Essential Terms for Beginners
deepdev.org-100 Essential Terms for Beginners
deepdev.org/blog/javascript-glossary-terms-for-beginners
2. Constant A container for storing data values that cannot be changed after
declaration.
const PI = 3.14159;
PI = 3.14; // This would cause an error
3. Data type The classification of data that tells the compiler or interpreter how to use
that data.
1/17
4. String A sequence of characters enclosed in single or double quotes.
5. Number A numeric data type that includes integers and floating-point numbers.
6. Boolean A logical data type that can have only two values: true or false.
7. Undefined A variable that has been declared but not assigned a value.
let undefinedVariable;
console.log(undefinedVariable); // Output: undefined
let person = {
name: "John",
age: 30,
isStudent: false
};
function greet(name) {
return "Hello, " + name + "!";
}
console.log(greet("Alice")); // Output: Hello, Alice!
2/17
13. Conditional statement Code structures that execute different actions based on
specified conditions.
14. Loop A control structure that repeats a block of code multiple times.
15. Console.log() A method used to output messages to the console for debugging.
16. Alert() A method that displays a dialog box with a message and an OK button.
alert("Hello, World!");
17. Prompt() A method that displays a dialog box asking the user to input some text.
18. Comment Text in the code that is ignored by the JavaScript engine, used for
explanations.
/*
This is a
multi-line comment
*/
20. Camel case A naming convention where the first word is lowercase and subsequent
words start with uppercase.
3/17
21. Concatenation The process of combining two or more strings.
22. Template literal A way to create strings that allows embedded expressions and
multi-line strings.
let x = 5;
let y = 10;
console.log(x < y); // true
console.log(x === 5); // true
27. Else statement Used with an if statement to execute a block of code when the if
condition is false.
4/17
let age = 16;
if (age >= 18) {
console.log("You're an adult");
} else {
console.log("You're a minor");
}
28. Else if statement Used to specify a new condition if the first condition is false.
29. Switch statement A control flow statement that executes different code blocks based
on different cases.
30. For loop A loop that repeats a block of code a specified number of times.
31. While loop A loop that executes a block of code as long as a specified condition is
true.
let i = 0;
while (i < 5) {
console.log(i);
i++;
}
5/17
32. Do...while loop A loop that executes a block of code once before checking the
condition, then repeats as long as the condition is true.
let i = 0;
do {
console.log(i);
i++;
} while (i < 5);
34. Continue statement Skips the rest of the current iteration and continues with the
next one.
37. Math object An object that provides mathematical operations and constants.
console.log(Math.PI); // 3.141592653589793
console.log(Math.round(4.7)); // 5
console.log(Math.random()); // Random number between 0 and 1
6/17
39. Return statement Used to specify the value that a function should return.
function add(a, b) {
return a + b;
}
console.log(add(5, 3)); // 8
function greet(name) {
console.log("Hello, " + name);
}
greet("Alice"); // "Alice" is an argument
42. Scope The context in which variables are declared and can be accessed.
43. Global scope Variables declared outside any function or block, accessible from
anywhere in the code.
44. Local scope Variables declared inside a function, only accessible within that
function.
function testScope() {
let localVar = "I'm local";
console.log(localVar); // Accessible
}
// console.log(localVar); // This would cause an error
45. Block scope Variables declared inside a block (like in an if statement or loop), only
accessible within that block.
if (true) {
let blockVar = "I'm in a block";
console.log(blockVar); // Accessible
}
// console.log(blockVar); // This would cause an error
46. Hoisting JavaScript's behavior of moving declarations to the top of their scope.
7/17
console.log(x); // undefined (not an error)
var x = 5;
function doSomething(callback) {
console.log("Doing something");
callback();
}
doSomething(() => console.log("Callback executed"));
48. Anonymous function A function without a name, often used as an argument to other
functions.
50. Ternary operator A shorthand way of writing an if-else statement in one line.
51. Truthy and falsy values Values that are considered true or false when evaluated in a
boolean context.
52. Type coercion Automatic conversion of values from one data type to another.
8/17
53. Strict equality Compares values without type coercion.
55. DOM (Document Object Model) A programming interface for HTML and XML
documents.
56. Event listener A function that waits for a specific event to occur.
document.getElementById("myButton").addEventListener("click", function()
{
console.log("Button clicked!");
});
function handleClick() {
console.log("Button clicked!");
}
document.getElementById("myButton").onclick = handleClick;
58. querySelector() Selects the first element that matches a CSS selector.
61. appendChild() Adds a node to the end of the list of children of a specified parent
node.
9/17
62. JSON (JavaScript Object Notation) A lightweight data interchange format.
63. AJAX (Asynchronous JavaScript and XML) A technique for creating fast and
dynamic web pages.
fetch("<https://api.example.com/data>")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
10/17
try {
// Code that might throw an error
throw new Error("Oops!");
} catch (error) {
console.error(error.message);
}
function divide(a, b) {
if (b === 0) {
throw new Error("Cannot divide by zero");
}
return a / b;
}
try {
throw new Error("Custom error message");
} catch (error) {
console.log(error.name); // "Error"
console.log(error.message); // "Custom error message"
}
70. Destructuring assignment A way to unpack values from arrays or properties from
objects into distinct variables.
71. Spread operator Allows an iterable to be expanded in places where zero or more
arguments or elements are expected.
function sum(...numbers) {
return numbers.reduce((total, num) => total + num, 0);
}
console.log(sum(1, 2, 3, 4)); // 10
11/17
function greet(name = "Guest") {
console.log(`Hello, ${name}!`);
}
greet(); // "Hello, Guest!"
greet("Alice"); // "Hello, Alice!"
74. Template tag function A function that can be used to modify the output of a template
literal.
75. Map object A collection of key-value pairs where both the keys and values can be of
any type.
78. Iterator An object that defines a next() method to access the next item in a
collection.
79. Generator function A function that can be paused and resumed, yielding multiple
values.
12/17
function* numberGenerator() {
yield 1;
yield 2;
yield 3;
}
let gen = numberGenerator();
console.log(gen.next().value); // 1
// math.js
export function add(a, b) {
return a + b;
}
82. Export statement Used to export functions, objects, or primitive values from a
module.
83. Closure A function that has access to variables in its outer (enclosing) lexical scope.
function outer() {
let x = 10;
return function inner() {
console.log(x);
};
}
let closureFn = outer();
closureFn(); // 10
84. Higher-order function A function that takes one or more functions as arguments or
returns a function.
function multiplyBy(factor) {
return function(number) {
return number * factor;
};
}
let double = multiplyBy(2);
console.log(double(5)); // 10
13/17
85. Pure function A function that always returns the same output for the same input and
has no side effects.
function add(a, b) {
return a + b;
}
function factorial(n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
console.log(factorial(5)); // 120
87. Memoization An optimization technique that stores the results of expensive function
calls.
function memoize(fn) {
const cache = {};
return function(...args) {
const key = JSON.stringify(args);
if (key in cache) {
return cache[key];
}
const result = fn.apply(this, args);
cache[key] = result;
return result;
};
}
88. Prototype The mechanism by which JavaScript objects inherit features from one
another.
function Person(name) {
this.name = name;
}
Person.prototype.greet = function() {
console.log(`Hello, I'm ${this.name}`);
};
let person = new Person("Alice");
person.greet(); // "Hello, I'm Alice"
14/17
class Animal {
constructor(name) {
this.name = name;
}
}
class Dog extends Animal {
bark() {
console.log("Woof!");
}
}
90. Class A template for creating objects, providing initial values and implementations.
class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
area() {
return this.height * this.width;
}
}
91. Constructor A special method for creating and initializing objects created within a
class.
class Person {
constructor(name) {
this.name = name;
}
}
let person = new Person("Alice");
let person = {
name: "Alice",
greet() {
console.log(`Hello, I'm ${this.name}`);
}
};
person.greet(); // "Hello, I'm Alice"
93. Static method A method that belongs to the class itself rather than to instances of
the class.
15/17
class MathOperations {
static square(x) {
return x * x;
}
}
console.log(MathOperations.square(5)); // 25
class Circle {
constructor(radius) {
this._radius = radius;
}
get diameter() {
return this._radius * 2;
}
}
let circle = new Circle(5);
console.log(circle.diameter); // 10
class Circle {
constructor(radius) {
this._radius = radius;
}
set radius(value) {
if (value > 0) {
this._radius = value;
}
}
}
let circle = new Circle(5);
circle.radius = 10;
96. This keyword A keyword that refers to the object it belongs to.
let person = {
name: "Alice",
greet() {
console.log(`Hello, I'm ${this.name}`);
}
};
person.greet(); // "Hello, I'm Alice"
97. Bind(), call(), and apply() methods Methods used to set the this value for a function.
16/17
function greet(greeting) {
console.log(`${greeting}, I'm ${this.name}`);
}
let person = { name: "Alice" };
greet.call(person, "Hi"); // "Hi, I'm Alice"
greet.apply(person, ["Hello"]); // "Hello, I'm Alice"
let boundGreet = greet.bind(person);
boundGreet("Hey"); // "Hey, I'm Alice"
99. Proxy object An object that wraps another object and intercepts operations.
let obj = { x: 1, y: 2 };
console.log(Reflect.has(obj, 'x')); // true
Reflect.set(obj, 'z', 3);
console.log(obj.z); // 3
17/17