JavaScript: Passing Values by Reference or by Value

In JavaScript, the way values are passed depends on whether they are primitive types or objects. Primitive types, which include numbers, strings, booleans, null, undefined, and symbols, are passed by value. When a primitive value is passed to a function, a copy of that value is made, and any modifications made to the copy will not affect the original value. For example: const increment = num => { num = num + 1; } const num = 2; increment(num); console....

Johnny Five Tutorial: Learn How to Interface with Electronic Devices using JavaScript

Johnny Five is a fantastic library that allows developers to communicate with electronic devices using JavaScript. While devices like Arduino are typically programmed in the Arduino Language, Johnny Five enables us to interface with Arduino using JavaScript, particularly in Node.js. Setting up your Arduino to work with Johnny Five To get started, follow these steps: Download the Arduino IDE from http://arduino.cc/en/main/software. Connect your Arduino board to a USB port on your computer....

Johnny Five: How to Use a REPL for Embedded Development

This post is part of the Johnny Five series. See the first post here. When working with Johnny Five, it’s important to understand the concept of a REPL (Read-Evaluate-Print-Loop). The REPL allows us to interactively write and execute code in the terminal. To start using the REPL, create a repl.js file with the following code: const { Board } = require("johnny-five"); const board = new Board(); In this example, we’ll be using an LCD circuit that we created in a previous lesson....

Keep Your Code Clean with ESLint

Learn the basics of ESLint, the most popular JavaScript linter that can help you adhere to syntax conventions, identify potential problems in your code, and enforce a set of standards defined by you or your team. What is a Linter? A linter is a tool that identifies issues in your code. When you run a linter against your code, it can tell you if your code follows specific syntax conventions, contains potential sources of problems, and matches a set of defined standards....

Lazy Loading Modules in Next.js: Optimize Your Application for Performance

Lazy loading modules in your Next.js app is a great way to optimize your application and improve performance. One module that we often need to load in specific parts of our app is the Moment library for handling date and time. In this article, we will explore how to lazy load the Moment library in Next.js and improve the performance of your app. To begin, let’s install the Moment library by running the following command in your terminal:...

Learn how to Use Redux to Manage your Application State

Redux is a popular state management library that is commonly used with React applications, although it can be used with other technologies as well. This guide will provide a simple and easy-to-follow overview of Redux and how to use it effectively. Why you need Redux Redux provides a way to manage the state of your application by moving it to an external global store. While React has its own method for managing state, Redux becomes necessary for complex applications where you find yourself moving state up and down the component tree using props....

Learn How to Use the Vue.js CLI

Vue.js is an impressive project that offers a range of utilities to make a Vue programmer’s life easier. One such utility is the Vue CLI, which stands for Command Line Interface. In this blog post, we will explore how to use the Vue CLI to create and manage Vue projects. Installation To start using the Vue CLI, you need to install it globally on your system by running the following command:...

Learning to Code: The Time Investment

Coding is a challenging endeavor that requires a significant time commitment. There are no shortcuts or quick fixes when it comes to learning how to code. If you’re starting from scratch and aspire to become a software engineer, be prepared to invest a great deal of effort and dedication. Becoming a developer necessitates a deep commitment to learning over an extended period. Fortunately, this mainly boils down to time. Unlike many other pursuits, coding does not require any special innate abilities or physical attributes typically associated with other fields....

Let vs Const in JavaScript: Making the Right Choice for Variable Declarations

When it comes to declaring variables in JavaScript, we often have two options: let and const. But which one should you choose? In this article, we’ll explore the differences between let and const and discuss when to use each. By default, I always prefer using const for my variable declarations. Why? Because const ensures that the value of the variable cannot be reassigned. As a developer, I always strive to use the approach that poses the least risk....

Linking two pages in Next.js using Link

How to link two or more pages in Next.js This tutorial builds upon the first Next.js tutorial, which covers how to install Next.js. In the previous tutorial, we created a website with a single page. Now, we want to add a second page to our website, a blog posts list. This page will be served at /blog and initially, it will be a simple static page similar to our index.js component....