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

How to prepend a value to the beginning of a JS array

To add a new value to the beginning of the JS array, you can use the function Array.unshift. Here鈥檚 how it works. ...

February 6, 2022 路 1 min 路 Coderslang Master

Loose equality in JavaScript

Loose equality in JS in a powerful tool that allows you to loosely compare different values. If the types of the values don鈥檛 match, JavaScript will do a typecast (most often to a string type) and then do the comparison....

February 5, 2022 路 1 min 路 Coderslang Master

Rules for comparing numbers in JavaScript

Nothing can be simpler than comparing two numbers. However, there are some details that you need to know about comparing numbers in JS. ...

February 4, 2022 路 1 min 路 Coderslang Master

Zero and Minus Zero in JavaScript

In JavaScript, there are 2 different zeros. A regular 0 is a bit different from -0 in JS. ...

February 3, 2022 路 1 min 路 Coderslang Master

Strict Equality in JavaScript

You can check strict equality in JavaScript using the operator ===. This operator does strict comparison and considers the operands equal if they鈥檙e of the same type, and their values are equal. ...

February 2, 2022 路 1 min 路 Coderslang Master

The difference between invisible and hidden HTML elements

In HTML there are 2 ways to hide an element. You can either make it invisible or make it hidden. The difference between a hidden HTML element and an invisible one is the amount of space occupied by the HTML element....

February 1, 2022 路 1 min 路 Coderslang Master