== vs === When working with JavaScript, you may come across the operators == and ===. These operators are used for comparing values in JavaScript, but they work in slightly different ways. In this blog post, we’ll explore the differences between == and === in JavaScript and when you should use each one.
The == operator is known as the equality operator. It is used to compare the values of two operands, and if they are equal, it returns true.
#Why type=“module” is used in the <script> element?
Rather than writing out whole Javascript application in one big file, it can be broken down into multiple files called modules. Modules are just .js files which can be imported into other files and has some exported code (functions or variables).
export const USER_ACCESS_TYPES = { admin: "full access", contributor: "read, write access", user: "read access", }; export const getUserAccessType = (userType) => { return USER_ACCESS_TYPES[userType]; }; These values can be imported in other script files and used.
This post will focus on the various loops available in the javascript and when to use them.
for - Probably the most commonly used loop in any programming language. The for loop runs until a specific condition is true. As seen below, it has 3 parts: i) initialization (i=0)
ii) condition (i<5)
iii) increment/decrement (i++/i--)
for (let i = 0; i < 5; i++) { console.log(i); } for (let i = 5; i >= 0; i--) { console.
There are few console methods available in Javascript, console.log being the most common one. Each of these variations of console methods could and should be used depending on type of data to output.
console.log() - As mentioned earlier console.log() is the most common console method and can be used to output any kind of data. console.log(); const message = "Hello world"; const num1 = 10; const num2 = 20; console.
We will understand and see how to create an executable javascript file using a global command.
Lets say for example you want to create a clone of ‘ls’ or ‘cmd’ command which shows the content of the current folder or from the path provided. To acheive that we need to have a global command.
To acheive this we need to do couple of things and need to have 2 files (index.