Lumir Technical Blog
website·Indexed 33 days ago
https://blog.lumir.page/A collection of technical guides and articles covering web development fundamentals, including JavaScript, Node.js, React, and Next.js. The documentation provides insights on npm packages like dotenv and Babel, Git version control best practices, HTML formatting, and software development naming conventions.
What's inside Lumir
- Originally a client-side scripting language for basic tasks like data validation, JavaScript has evolved into a full programming language capable of complex calculations, metaprogramming, closures, and anonymous (lambda) functions. Its ecosystem has expanded through key technologies: jQuery simplified DOM manipulation, and Node.js enabled the use of JavaScript for server-side development.
Understand the difference between Frameworks and Libraries
The fundamental difference between a framework and a library is the Inversion of Control (IoC), which determines who owns the application's control flow.
- Library: The developer maintains control. The developer decides when to call a specific function or class from the library to perform a task. The library is an auxiliary tool used by the developer's code.
- Framework: The framework maintains control. It provides a skeleton or blueprint for the application and defines the flow. The developer plugs their code into specific positions defined by the framework, and the framework calls the developer's code when needed (Inversion of Control).
Key trade-offs include:
- Replaceability: Libraries are easily replaced; frameworks are difficult to change once adopted.
- Integration: Libraries can be added to existing programs easily; frameworks often require a complete project structure to be built around them.
- Performance: Libraries generally have faster loading times and less overhead than full-scale frameworks.
Compare Visual Studio Code and Visual Studio for development
Choosing between Visual Studio Code (VS Code) and Visual Studio depends on whether you need a lightweight, extensible editor or a full-featured Integrated Development Environment (IDE).
Visual Studio Code (VS Code) is a fast, lightweight, cross-platform editor (Windows, macOS, Linux) built on Electron and Node.js. It provides basic text editing by default and relies on extensions to provide IDE-like features such as debugging, linting, and language-specific Intellisense. It is highly flexible and widely used across various roles and languages, though it requires manual configuration of development environments.
Visual Studio is a comprehensive IDE primarily for Windows and macOS. It is a 'finished product' that includes built-in support for software analysis, testing, deployment, and deep optimization for .NET and C-family languages. It is heavier and slower to load than VS Code, especially for large projects, but eliminates the need to manually configure separate development environments.
Understand the JavaScript Browser Environment Composition
In a web browser (client) environment, JavaScript is composed of a top-level global object (
window) and three primary lower-level components:- Core (ECMAScript): The language specification including syntax, types, operators, and keywords. This is independent of the host environment.
- Document Object Model (DOM): An API used to manipulate web page content and HTML tags.
- Browser Object Model (BOM): Objects and methods used to interact with the browser window and environment outside of the document content.
Manage Node.js versions using nvm
nvm (Node Version Manager) is a command-line tool that allows developers to quickly install and switch between different versions of Node.js on a single machine.Use GitHub Issues for task and bug tracking
GitHub Issues is an integrated collaboration tool used to track bugs, schedules, ideas, feedback, and documentation changes directly within a GitHub repository. It integrates with Pull Requests and can be automated via GitHub Workflows.Implement Markdown substitutions using Regular Expressions
To implement a custom Markdown substitution (preprocessing) system, use JavaScript'sreplacefunction with regular expression capture groups. This allows you to identify specific substitution patterns (such as{/* ... */}) and transform the inner content using a callback function before the Markdown is converted to JSX or HTML. To maintain performance, apply this conversion logic only to the necessary parts of the document rather than the entire file.// Example: Extracting and processing content within {/* ... */} substitutions const example = '{/* Make This Sentence Lower Case */}'; const exampleProcessed = example.replace(/\{\/\*\s*(.+?)\s*\*\/\}/, (_, p1) => p1.toLowerCase(), ); console.log(exampleProcessed); // 'make this sentence lower case'Install all project dependencies from package.json
Running
npm installwithout a package name downloads all dependencies listed independenciesanddevDependencieswithin thepackage.jsonfile.To install ONLY production dependencies (skipping
devDependencies), use the--productionflag. This is useful for deployment environments to reduce image size and installation time.# Install all dependencies npm install # Install only production dependencies npm install --productionUse Visual Studio Code for lightweight and cross-platform development
Use Visual Studio Code when you need a fast, lightweight editor that works across Windows, macOS, and Linux. It is particularly well-suited for Node.js, JavaScript, and TypeScript due to built-in support, but can be extended for .NET, Unity, C++, C#, Java, Python, PHP, and Go via extensions.
Key capabilities provided via extensions include:
- Syntax highlighting and bracket matching
- Intellisense for variables and methods
- Debugging and linting
- Multi-cursor editing and code navigation
- Git support and refactoring
Enforce pull request requirements before merging
Enable 'Require a pull request before merging' to block direct pushes to a protected branch. This forces developers to use a separate feature branch and a Pull Request (PR) for all changes. Available sub-options include:
- Require approvals: Set the minimum number of required approvals before a merge is allowed.
- Dismiss stale pull request approvals when new commits are pushed: Invalidates existing approvals if new code is pushed to the PR branch.
- Require review from Code Owners: Forces approval from designated code owners for files they own.
- Require approval of the most recent reviewable push: Ensures the final version of the code is approved by someone other than the person who pushed it.
Create unordered lists in Markdown
Unordered lists are created using-,*, or+symbols. These symbols can be mixed. Indentation is used to create nested list levels, which may change the bullet shape in the rendered output.- red - green - blue * red * green * blue + red + green + blueUse console.log() for general debugging and HTML-like DOM output
console.log()is used for general debugging, logging, and troubleshooting. When printing DOM elements, it outputs them in a tree structure similar to HTML, making it useful for inspecting the tag content of an element.// Example of using format specifiers with console.log() console.log('Number: %d', 273); console.log('String: %s', 'hi~'); console.log('Json: %j', {name:'jay'});