Introduction

  1. Javascript related

    1. Components of JS in the Browser

      1. JS core syntax: variable/data type, loop/branch/judgment, function/scope/this, etc…

      2. WebAPI: DOM manipulation, BOM manipulation, Ajax manipulation, etc…


    2. How JS is executed in the browser

      Browsers have Javascript parsing engines. Different browsers use different engines, among which Chrome’s V8 parsing engine has the best performance.


    3. Why JS can manipulate DOM and BOM

      Each browser has built-in API functions such as DOM and BOM, so the JS in the browser can call them.


    4. The JavaScript runtime environment in the browser

      The runtime environment refers to the necessary environment for the code to function properly. The browser is the operating environment. Take Chrome as an example:

      To execute JS code normally, it requires V8 engine, built-in API (DOM, BOM, XMLhttp, JS built-in objects, Canvas, etc.). The JS code to be executed calls the built-in API, and then handed over to the V8 engine to run.

      Therefore, you cannot call built-in APIs such as DOM without the browser environment.


    5. Can JS be used for back-end development?

      Back-end development languages: Java, Python, PHP. The running environment of JS for back-end development is Node.js. ie Node.js is a backend runtime environment.


  2. Introduction to Node.js

    Node.js is a Javascript runtime environment based on the Chrome V8 engine.

    Node.js operating environment: V8 engine, built-in API (fs, path, http, JS built-in objects, querystring, etc.). So in-browser APIs like DOM, BOM, and Ajax cannot be called from Node.js.


    Node.js only provides basic functions and APIs, but there are many powerful tools and frameworks based on Node.js:

    1. Express framework, quickly build web applications

    2. Electron framework for building cross-platform desktop applications

    3. restify framework, quickly build API interface projects

    4. Read, write and operate databases, create practical command-line tools to assist front-end development, etc…


  3. Node.js Learning Pathway

    JS learning path in the browser: JS basic syntax, browser built-in API (DOM, BOM, etc..), third-party libraries (jQuery, etc.).

    Node.js learning path: JS basic syntax (same as browser), Node.js built-in API modules (fs, path, http, etc.), third-party API modules (express, mysql, etc.).


  4. nodemon

    Usefulness: When writing a Node.js project, if the code is modified, it needs to be manually closed frequently and then restarted, which is very cumbersome. The nodemon tool can monitor changes in project files. When the code is modified, nodemon will automatically restart the project for us, which greatly facilitates development and testing.

    Install (globally): npm install -g nodemon

    Startup file: nodemon js file path

    The reason for wanting to install a package globally is usually that we want to run the package directly from the command line, like nodemon and create-react-app.


    If .ps1 is not digitally signed. The script will not execute on the system. pops up, enter the command first.

    1
    Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass


Share