The difference between dependencies and devDependencies in package.json

The file package.json is an integral part of every Node.js project. It stores all the dependencies that your project needs. All the dependencies (most often open-source npm modules) are split into two categories: production dependencies and development dependencies....

June 2, 2022 路 2 min 路 Coderslang Master

4 JavaScript array functions that every Junior must know

If you鈥檙e new to JavaScript arrays, you鈥檇 be surprised how many useful built-in functions they have. Today, I鈥檒l show you 4 of them. You can also get a deeper dive into a specific topic by reading dedicated articles:...

June 1, 2022 路 2 min 路 Coderslang Master

How to transform a JS array with "map"

In this tutorial you鈥檒l learn how you can use the function map to transform the JavaScript array by applying a mapping function to all of its elements. The biggest drawback of the forEach loop is that it doesn鈥檛 return anything useful....

May 20, 2022 路 2 min 路 Coderslang Master

How to reduce a JavaScript array to a single value

The reduce function is the most complex of the standard JavaScript array functions. With reduce, you can compress (reduce) an array to one element. For the reduce function to work properly, you鈥檒l need 2 parameters 鈥 the reducer function and the initial value....

May 19, 2022 路 4 min 路 Coderslang Master

How to filter out array elements in JS

The built-in array function filter will help you filter out the unwanted elements from the array and return a new array consisting only of suitable items. To work correctly, the filter function accepts a parameter called 鈥渇iltering function鈥 or 鈥渇iltering predicate鈥....

May 18, 2022 路 2 min 路 Coderslang Master

How to iterate over the array in JavaScript with forEach

Iterating over the elements of the array in JavaScript is a very common task. In this tutorial you鈥檒l learn how to use the built-in array function forEach to go over all array elements....

May 17, 2022 路 2 min 路 Coderslang Master

What is the --save option for npm install

The --save option for npm install or npm i allows you to add the npm module you鈥檙e installing to the file package.json. This way it鈥檒l become one of the project dependencies and will be automatically installed the next time you run npm install....

May 9, 2022 路 1 min 路 Coderslang Master

What is the difference between ~ and ^ in package.json?

Node package manager supports semantic versioning. To take full advantage of it, you can use the symbols tilde(~) or caret(^). Tilde(~) means approximately equivalent to version. "moment": "~2.29.1" In this example npm install will pick up the latest release of the module moment starting from 2....

February 19, 2022 路 1 min 路 Coderslang Master

Check for an empty value in JavaScript

When I started learning JS, one of the most powerful tools I discovered, was the ability to check if a variable is empty. My definition of emptiness was hardly a scientific one as I didn鈥檛 mean to check if it was defined or not....

February 8, 2022 路 1 min 路 Coderslang Master

Get random integer in a range using JavaScript

Similarly to generating a random float number within the specific range, you can write a function to get a random integer with a range. function getRandomIntegerInRange(min, max) { return Math.floor(Math.random() * (Math....

February 7, 2022 路 1 min 路 Coderslang Master