JS CheatSheet

Master modern JavaScript with our organized reference toolkit. Explore String methods, Array logic, and DOM interactions with live examples.

Extraction

String.slice()

Extraction

Extracts a part of a string and returns it as a new string. Support negative indices.

Syntax
str.slice(start, end)
Usage Example
"NexsaConvert".slice(0, 5); // "Nexsa"
Nexsa Logic Guide

String.substring()

Extraction

Similar to slice, but treats negative indices as 0.

Syntax
str.substring(start, end)
Usage Example
"Nexsa".substring(1, 4); // "exu"
Nexsa Logic Guide

String.charAt()

Extraction

Returns the character at a specified index.

Syntax
str.charAt(index)
Usage Example
"Nexsa".charAt(0); // "N"
Nexsa Logic Guide

Modification

String.replace()

Modification

Replaces a specified value with another value in a string (first match).

Syntax
str.replace(search, replace)
Usage Example
"Blue car".replace("Blue", "Red"); // "Red car"
Nexsa Logic Guide

String.replaceAll()

Modification

Replaces all occurrences of a string or pattern.

Syntax
str.replaceAll(search, replace)
Usage Example
"apple pie".replaceAll("p", "b"); // "abble bie"
Nexsa Logic Guide

String.trim()

Modification

Removes whitespace from both ends of a string.

Syntax
str.trim()
Usage Example
" Nexsa ".trim(); // "Nexsa"
Nexsa Logic Guide

Case Conversion

Modification

Converts a string to all uppercase or lowercase letters.

Syntax
str.toUpperCase() / .toLowerCase()
Usage Example
"Nexsa".toUpperCase(); // "NEXSA" "Nexsa".toLowerCase(); // "nexsa"
Nexsa Logic Guide

Search

String.includes()

Search

Returns true if a string contains a specified value.

Syntax
str.includes(searchString)
Usage Example
"Nexsa".includes("Nex"); // true
Nexsa Logic Guide

Starts / Ends With

Search

Checks if a string begins or ends with specific characters.

Syntax
str.startsWith() / .endsWith()
Usage Example
"Hello".startsWith("H"); // true "Hello".endsWith("o"); // true
Nexsa Logic Guide

indexOf

Search

Returns the index of the first occurrence of a value, or -1 if not found.

Syntax
str.indexOf(value)
Usage Example
"Nexsa".indexOf("u"); // 3
Nexsa Logic Guide

Padding

Padding

Padding

Pads the string with another string until it reaches the given length.

Syntax
str.padStart(len, char) / .padEnd()
Usage Example
"5".padStart(3, "0"); // "005"
Nexsa Logic Guide

String.repeat()

Padding

Returns a new string containing the original string repeated.

Syntax
str.repeat(count)
Usage Example
"Ha".repeat(3); // "HaHaHa"
Nexsa Logic Guide

Conversion

String.split()

Conversion

Splits a string into an array of substrings based on a separator.

Syntax
str.split(separator)
Usage Example
"a,b,c".split(","); // ["a", "b", "c"]
Nexsa Logic Guide

Mastering Modern ECMAScript Environments

JavaScript is no longer a simple scripting language. From the V8 engine's optimization of hidden classes to the nuances of the Event Loop and Microtask queue, our Pro Cheat Sheet distills decades of language evolution into actionable, high-precision snippets.

Expert Implementation

Closures & Scope Chain Logic

Understanding how the Lexical Environment persists through closures is the hallmark of a senior engineer. Our reference guide provides clear, non-generic examples of asynchronous iteration, prototype inheritance, and modern pattern matching to help you write cleaner, more efficient code.

JS Engine Specs

StandardECMAScript-2024-Ready
ParadigmMulti-Functional-Hybrid
CapabilityFull-Async-Await

JavaScript Engineering FAQs

What is the difference between map() and forEach()?

`map()` creates and returns a new array with the results of the callback, while `forEach()` just executes the callback and returns `undefined`.

How does the Event Loop handle Promises?

Promises are pushed to the Microtask Queue, which has higher priority than the standard Task Queue (Macrotasks like setTimeout). They are processed immediately after the current script executes.

Is 'this' always bound to the object?

No. The value of `this` depends on how the function is called. In Arrow Functions, `this` is lexically bound—it inherits the value from the surrounding scope.

Why use 'use strict'?

Strict mode prevents common mistakes like using undeclared variables and makes certain 'silent errors' throw exceptions, leading to better-quality code.