Saturday, April 18, 2020

Safety datasets

These are safety datasets EX CM AE DS MH IE LB VS
Which datasets are SAFETY datasets? AE CM DS EX MH IE LB VS

ES6 Super quick reference

Arrow functions:

// ES5
function sayHello (name) {
  return 'Hello ' + name
}

// ES6
const sayHello = (name) => 'Hello ' + name

console.log(sayHello('Ramesh'))

Variables:

var firstName = 'Ramesh'; // ES5

let firstName = 'Ramesh' // ES6 - have block scope

const firstName = 'Ramesh' // ES6 - as it says, it's a constant

Template Strings:

let strWelcome = 'Welcome'
// use the backticks to combine strings with variables
let templateString = `${strWelcome} Ramesh` console.log(templateString)

async await:

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await

Destructuring:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Shorthand objects

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer

Function arguments

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments

Expand arrays

https://www.smashingmagazine.com/2016/07/how-to-use-arguments-and-parameters-in-ecmascript-6/
let myArray = [1,2,3]
Math.max(...myArray)

Classes

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class

nvm - switch node versions with nvm

Node Version Manager (nvm) helps to switch between different versions of nodejs. This article provides all the details on nvm:

Some basic commands:
  • To install nvm on mac: brew install nvm
  • To install nodejs using nvm: nvm install node
  • To install a specific version of nodejs: nvm install 13.5.0
  • To use a specific version as default: nvm alias default 12.16.1
  • To see what versions are available on your local: nvm list
  • To use a specific version: nvm use <version number>
References:

https://michael-kuehnel.de/node.js/2015/09/08/using-vm-to-switch-node-versions.html

https://www.kulik.io/2019/05/01/set-default-node-version-using-nvm/

https://nodesource.com/blog/installing-node-js-tutorial-using-nvm-on-mac-os-x-and-ubuntu/

npx - Installation-less command execution

You don't want to install some command but you want to use it on the fly! Well, npx comes to your rescue: https://nodejs.dev/the-npx-nodejs-package-runner

For a quick understanding of differences between npm and npx, read this: https://stackoverflow.com/questions/50605219/difference-between-npx-and-npm

Also read the interesting facts about Node.js: https://nodejs.dev/a-brief-history-of-nodejs

Read thru this article that would help better understand an executable global module: https://medium.com/jspoint/creating-cli-executable-global-npm-module-5ef734febe32

Thursday, April 16, 2020

About JavaScript modules, module formats, module loaders, module builders

This article was written in 2017 and I was NOT blessed to read this till now. Well, better late than nothing. You want to know the intricacies of JavaScript modules, this is it, you have to read this.

Here is the link to the article: https://www.jvandemo.com/a-10-minute-primer-to-javascript-modules-module-formats-module-loaders-and-module-bundlers/

And then follow this article: https://www.sitepoint.com/understanding-module-exports-exports-node-js/, that explains the additional details of how to use nodeJS modules.