Tuesday, November 9, 2021

Getting started with Node.js 2021-2022

common file names conventions

app.js, server.js, index.js

index.js : contains code for server side logic. index.js is the server code file


npm run build: will run utilities to build and bundle javascript files if possible. After generating the bundle.js, be sure to include it in a script tag in the HTML file. 

npm run start

The request module has been deprecated. Many web API requests make use of this module. Using this module will throw errors. MDN Fetch API "This kind of functionality was previously achieved using XMLHttpRequest. Possible alternative: Fetch provides a better alternative that can be easily used by other technologies such as Service Workers. Fetch also provides a single logical place to define other HTTP-related concepts such as CORS and extensions to HTTP." Mozilla MDN

Global scope: publicly available variables at the top level of a browser window

If a JavaScript variable is initiated without value, the default is undefined. let myVar; myVar == undefined; // returns true

Old way of declaring variable is using var, global scope. The new way is let and const. let and const are better for block scope declaration? 

Image Processing Library for Node.js
Sharp is a high-performance module for resizing and formatting

Shopify offers Shopify CLI command line tool rails or node.js

Going beyond basic console logging in JavaScript:
  • console logging error
    • console.error('error message or code')
  • console log warning message in JavaScript
    • console.warn('message')
  • console logging time
    • console.time('label') // print out time with the label
    • console.timeEnd('label') measure how long the script takes
  • clear console
    • console.clear()
  • Print out complex console log message in table structures, returns a nice table
    • console.table({object key : value})

No comments:

Post a Comment

React UI, UI UX, Reactstrap React Bootstrap

React UI MATERIAL  Install yarn add @material-ui/icons Reactstrap FORMS. Controlled Forms. Uncontrolled Forms.  Columns, grid