In this Article we will go through how to get the arrays of digits from a number only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const digitize = n => `${n}`.split('').map(v => parseInt(v, 10));
In this Article we will go through how to multiply arguments only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const mul = (...args) => args.reduce((a, b) => a * b);
In this Article we will go through how to prefix an integer with zeros only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const prefixWithZeros = (number, length) => (number / Math.pow(10, length)).toFixed(length).substr(2);
In this Article we will go through how to calculate the division of arguments only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const division = (...args) => args.reduce((a, b) => a / b);
In this Article we will go through how to calculate the factorial of a number only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const factorial = n => n <= 1 ? 1 : n * factorial(n - 1);
In this Article we will go through how to calculate the mod of collection index only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const mod = (a, b) => ((a % b) + b) % b;
In this Article we will go through how to calculate the remainder of division of arguments only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const remainder = (...args) => args.reduce((a, b) => a % b);
In this Article we will go through how to calculate the sum of arguments only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const sum = (...args) => args.reduce((a, b) => a + b);
In this Article we will go through how to run promises in sequence only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
const run = promises => promises.reduce((p, c) => p.then(rp => c.then(rc => [...rp, rc])), Promise.resolve([]));
In this Article we will go through how to swap two variables only using single line of code in JavaScript. This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function.
Let's define this short function:
[a, b] = [b, a];