What is npm-shrinkwrap ?
npm-shrinkwrap command locks down the versions of a package’s dependencies so that you can control exactly which versions of each dependency will be used when your package is installed.
References
- https://docs.npmjs.com/cli/shrinkwrap
ES6 Spread Syntax
The spread syntax allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) or multiple variables (for destructuring assignments) are expected.
Spread syntax can be only applied to iterable objects.
Rest syntax looks exactly like spread syntax. In a way, rest syntax is the opposite of spread syntax. Spread syntax “expands” an array into its elements, while rest syntax collects multiple elements and “condenses” them into a single element.
function sum(a, b) {
return a+b;
}
const args = [1, 2];
let result = sum(...args);
console.log(result); // 3const arr = [1, 2, 3];
const arrCopy = [...arr];
console.log(arrCopy); // [1, 2, 3]References
What is a React Pure Component ?
If React components render() function renders the same result given the same
props and state , you can use PureComponent for a performance boost.
PureComponent’s shouldComponentUpdate() function only shallow compares the objects.
Also its skips prop updates for the whole component subtree. So need to make
sure that all the children components are also “pure”.
Best use case for PureComponent are presentational components which have no
child components and no dependencies on the global state in the application.
class MyComponent extends React.PureComponent {
render() {
return (
<h1>Hello World!</h1>
);
}
}References
What is a Test Fixture ?
A test fixture is a fixed state of a set of objects used as a baseline for running tests. The purpose of test fixture is to ensure that there is a well known and fixed environment in which tests are run so that results are repeatable.
References
- https://github.com/junit-team/junit4/wiki/test-fixtures
Duck Typing in JavaScript ?
The term duck typing comes from the saying “If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck”.
Duck Typing helps to avoid conditional in JavaScript. Duck Typing helps to emulate interface interfaces in JavaScript.
References
- http://adripofjavascript.com/blog/drips/using-duck-typing-to-avoid-conditionals-in-javascript.html
- http://jscriptpatterns.blogspot.com/2013/01/javascript-interfaces.html
- https://en.wikipedia.org/wiki/Duck_typing