Morally Bankrupt Books
website·Indexed 30 days ago
https://morally-bankrupt-books.vercel.appA collection of educational guides and books covering Git and GitHub basics, as well as comprehensive JavaScript tutorials based on Eloquent JavaScript, including DOM manipulation, Node.js, and functional programming.
What's inside Morally Bankrupt Books
- Programming is the act of constructing a program—a set of precise instructions telling a computer what to do. Because computers are limited to simple, logical operations, programming requires rigor and abstract thinking. JavaScript is a programming language built into every modern web browser, making it available on almost every device for creating custom functionality where standard applications are insufficient.
Design a grid-based platform game using the DOM
A minimalist 2D platform game can be implemented using the browser DOM by representing the static background as an HTML table (a grid of squares) and overlaying moving elements (actors) using absolutely positioned DOM elements. The game state tracks the player, coins, and lava. Movement is handled via keyboard events (arrow keys), and positions are stored as fractional coordinates to allow smooth motion between grid cells.Understand Synchronous vs Asynchronous Programming
In a synchronous programming model, tasks happen sequentially. A function performing a long-running action blocks the program until it returns a result. In an asynchronous model, the program can start an action and continue running other tasks. The program is notified when the asynchronous action finishes, allowing it to access the result without idling the processor during network requests or disk I/O.Use a README.md file for project documentation
TheREADME.mdfile (written in Markdown) serves as the introduction to a repository. It is essential for explaining what the project is about, which encourages other developers to use or contribute to the project. A well-documented README is critical for project discoverability and maintenance.Understand the basics of ES modules
ES modules (ECMAScript modules) provide a way to organize JavaScript code into separate scopes, avoiding the global scope pollution associated with traditional scripts. Modules useimportandexportkeywords to define their interface and dependencies. Unlike scripts, modules have their own separate scope, andimport/exportdeclarations must appear in the outer module body (not inside functions or loops).Understand JavaScript expressions and statements
In JavaScript, an expression is a fragment of code that produces a value. This includes literals (e.g.,
22), expressions wrapped in parentheses, or operators applied to other expressions.A statement is a full 'sentence' of code. The simplest statement is an expression followed by a semicolon. While expressions produce values, statements are used to perform actions or create side effects (such as modifying the state of the machine or printing to the console).
1; // A statement that produces 1 and then discards it !false; // A statement that produces true and then discards itUnderstand the purpose and benefits of Version Control Systems (VCS)
Version control (also known as Source Control, Source Code Management (SCM), or Revision Control Systems (RCS)) is a system used to track and manage changes to a file or set of files over time. It allows developers to maintain a history of changes, compare different versions, and revert to a previous working state if problems occur.
Key benefits include:
- Collaboration: Multiple people can work on the same project simultaneously and merge their work together.
- Audit Trail: Every change is recorded in a log, tracing exactly what was modified and by whom.
- Risk Mitigation: Prevents data loss by storing code in repositories; distributed systems (like Git) allow code to be stored both locally and on remote platforms (like GitHub), ensuring a backup exists if local hardware fails.
Implement a basic Stack data structure
A stack is a data structure that follows the Last-In-First-Out (LIFO) principle, where the last value pushed in is the first one popped out. In JavaScript, this is commonly implemented using an array withpushandpopmethods.Perform Logical Operations on Booleans
JavaScript uses three primary logical operators to reason about Boolean values:
&&(Logical AND): Returnstrueonly if both values are true.||(Logical OR): Returnstrueif at least one value is true.!(Logical NOT): A unary operator that flips the Boolean value.
Precedence Order (Lowest to Highest):
||(OR)&&(AND)- Comparison operators (
>,==, etc.) - Arithmetic operators
console.log(true && false); // → false console.log(false || true); // → true console.log(!true); // → false // Example of precedence: arithmetic -> comparison -> AND -> OR console.log(1 + 1 == 2 && 10 * 10 > 50);Secure communication with HTTPS
HTTPS (Secure HTTP) encrypts data to prevent eavesdropping and tampering. It uses cryptographic certificates issued by recognized certificate authorities to verify the server's identity, ensuring that the client is communicating with the intended website and not an impersonator.Node.js Asynchronous I/O Overview
All input and output in Node.js is performed asynchronously by default. While Node originally relied on callbacks, thenode:fs/promisespackage now provides a promise-based interface for filesystem operations. Synchronous variants of functions (e.g.,readFileSync) are available but should be used explicitly when blocking behavior is required.Manage code reuse with NPM packages
A package is a distributable chunk of code containing one or more modules and a list of its dependencies. NPM (Node Package Manager) provides the infrastructure to store, find, install, and upgrade these packages. This prevents code duplication and allows developers to maintain a single version of a utility across multiple projects.