What is process.env in Node.js

May 3, 2017

In Node.js, you can retrieve environment variables by key from process.env object.

node -p process.env
node -p process.env.HOME

References

  • http://stackoverflow.com/questions/15058954/node-js-is-there-any-documentation-about-the-process-env-variable
  • https://nodejs.org/api/process.html#process_process_env
  • https://davidwalsh.name/node-environment-variables
Categories : JavaScript   NodeJS

What is Git blame ?

May 1, 2017

Git blame helps in viewing the line by line revision history for an entire file.

References

  • https://zsoltfabok.com/blog/2012/02/git-blame-line-history/
  • https://help.github.com/articles/tracing-changes-in-a-file/
  • https://git-scm.com/docs/git-blame
Categories : Git

Imperative vs Declarative Programming

May 1, 2017

Declarative programming is more like what you do, or something. Imperative programming is like how you dome something. Declartive programming can be context-independent.

References

  • https://tylermcginnis.com/imperative-vs-declarative-programming/
Categories : JavaScript   Programming

Factory functions in JavaScript

Apr 27, 2017

Factories are simply functions that create objects. You can use factories instead of classes, and factories are simpler than classes and easier to reason about.

References

  • https://medium.com/humans-create-software/factory-functions-in-javascript-video-d38e49802555
  • https://medium.com/javascript-scene/javascript-factory-functions-vs-constructor-functions-vs-classes-2f22ceddf33e
  • https://www.sitepoint.com/factory-functions-javascript/
Categories : JavaScript

ES6 Destructuring

Apr 26, 2017

Destructuring assignment allows you to assign the properties of an array or object to variables using syntax that looks similar to array or object literals. This syntax can be extremely terse, while still exhibiting more clarity than the traditional property access. This new syntax was introduced in ECMAScript 2015 (ES6).

// Array destructuring
let arr = [1, 2, 3];
let [a, b, c] = arr;
console.log(a); // 1
console.log(b); // 2
console.log(c); // 3

// Object destructuring
let obj = {
    x: 1,
    y: 2
}

let {x, y} = obj;
console.log(x); //1
console.log(y); //2

References

Categories : ES6   JavaScript