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.

Tokens
16.4K
Snippets
111
Records
156
Agent score
47%

What's inside Lumir

  1. Overview of JavaScript capabilities and ecosystem

    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.
  2. 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.
  3. 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.

  4. 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:

    1. Core (ECMAScript): The language specification including syntax, types, operators, and keywords. This is independent of the host environment.
    2. Document Object Model (DOM): An API used to manipulate web page content and HTML tags.
    3. Browser Object Model (BOM): Objects and methods used to interact with the browser window and environment outside of the document content.
  5. 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.
  6. Implement Markdown substitutions using Regular Expressions

    To implement a custom Markdown substitution (preprocessing) system, use JavaScript's replace function 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'
  7. Install all project dependencies from package.json

    Running npm install without a package name downloads all dependencies listed in dependencies and devDependencies within the package.json file.

    To install ONLY production dependencies (skipping devDependencies), use the --production flag. This is useful for deployment environments to reduce image size and installation time.

    # Install all dependencies
    npm install
    
    # Install only production dependencies
    npm install --production
  8. Use 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
  9. 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.
  10. 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
        + blue
  11. Use 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'});