FOR TALENT
Blog Explore the trends. Codebrew Stay up to date. Interview Questions Get prepared. Coder Glossary Learn the concepts. Portfolio Showcase your projects. University Preferences Make the right choice. Roadmap Move forward step by step. Cheat Sheets Look up the shortcuts. Free Software Tools Get a hand. Podcast Listen on the go. Salaries Learn what the market pays. AI Tools Explore AI.FOR COMPANIES
Blog HR trends. Codebrew Stay in the loop. HR Webinars Hear from the experts. Case Studies Get inspired. E-book Download the guides. HR Calculation Tools Calculate with ease.
The most This cheat sheet covers the most common fundamentals of the JavaScript language. JavaScript reference card
// Hello World
// Basic Commands
// Getting Started Resources
// Primitive Data Types
// Type Conversion
let num = Number("123"); // 123
let str = String(123); // "123"
// Data Types Resources
// Arithmetic Operators
// Comparison Operators
// Logical Operators
// Operators Resources
// if-else Statement
let x = 10;
if (x > 5) {
console.log("Greater");
} else {
console.log("Smaller or equal");
}
// switch Statement
let day = 2;
switch (day) {
case 1:
console.log("Monday");
break;
case 2:
console.log("Tuesday");
break;
default:
console.log("Other");
}
// for Loop
for (let i = 0; i < 5; i++) {
console.log(i);
}
// for...of Loop
let arr = [1,2,3];
for (let n of arr) {
console.log(n);
}
// while Loop
let i = 0;
while (i < 3) {
console.log(i);
i++;
}
// do-while Loop
let i = 0;
do {
console.log(i);
i++;
} while (i < 3);
// Loop Control Keywords
// Control Flow Resources
// Function Declaration
function greet(name) {
return "Hello, " + name;
}
// Arrow Function
const greet = (name) => "Hello, " + name;
// Closure
function makeCounter() {
let count = 0;
return function() {
return count++;
};
}
// Functions Resources
// Object Creation
let car = {
brand: "Toyota",
start: function() {
console.log(this.brand + " is starting");
}
};
// Array Methods
let arr = [1, 2, 3];
arr.push(4); // [1, 2, 3, 4]
arr.pop(); // [1, 2, 3]
// Prototype
function Person(name) {
this.name = name;
}
Person.prototype.greet = function() {
console.log("Hello, " + this.name);
};
// Objects and Arrays Resources
// let and const
let x = 10;
const y = 20;
// Template Literals
let name = "World";
console.log(`Hello, ${name}!`);
// Destructuring
let [a, b] = [1, 2];
let {name, age} = {name: "Alice", age: 25};
// ES6 Features Resources
// Callbacks
function fetchData(callback) {
setTimeout(() => {
callback("Data fetched");
}, 1000);
}
// Promises
let promise = new Promise((resolve, reject) => {
resolve("Success");
});
promise.then(result => console.log(result));
// Async/Await
async function fetchData() {
let data = await fetch("/api/data");
console.log(data);
}
// Asynchronous JavaScript Resources
// Selecting Elements
let element = document.querySelector("#myElement");
// Event Handling
element.addEventListener("click", function() {
console.log("Element clicked");
});
// DOM Manipulation Resources
// try-catch
try {
let x = 1 / 0;
} catch (e) {
console.log("Error: " + e.message);
}
// Custom Error
class MyError extends Error {
constructor(message) {
super(message);
this.name = "MyError";
}
}
// Error Handling Resources
// Higher-Order Functions
function map(arr, func) {
let result = [];
for (let i = 0; i < arr.length; i++) {
result.push(func(arr[i]));
}
return result;
}
// IIFE
(function() {
console.log("IIFE");
})();
// Advanced Functions Resources
// ES6 Modules
export function greet() {
console.log("Hello");
}
import { greet } from "./module.js";
// Modules Resources
// Event Loop
console.log("Start");
setTimeout(() => {
console.log("Timeout");
}, 0);
console.log("End");
// Event Loop Resources
// Regex Syntax
let regex = /\d+/;
console.log(regex.test("123"));
// Regular Expressions Resources
// Debugging Tools
console.log("Debugging");
debugger;
// Debugging Resources
// Common Security Concerns
// Security Resources
// Optimization Tips
// Performance Resources
// Fetch API
fetch("/api/data")
.then(response => response.json())
.then(data => console.log(data));
// WebSockets
let socket = new WebSocket("ws://example.com/socket");
socket.onmessage = function(event) {
console.log("Data received: " + event.data);
};
// Web APIs Resources
// TypeScript Basics
let message: string = "Hello, TypeScript!";
// TypeScript Resources
// Jest Testing
test("adds 1 + 2 to equal 3", () => {
expect(1 + 2).toBe(3);
});
// Testing Resources
// JavaScript Best Practices
// Best Practices Resources
// JavaScript Tools
// JavaScript in Action
Get inspired, learn, join competitions and grow in your job!
Sign up now