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....

Pointers in Go: A Guide to Using Pointers in Go Programming

In Go programming, pointers are an essential concept to understand. They allow you to directly access and manipulate the memory address of a variable. This blog post will guide you through the basics of using pointers in Go. Let’s start with an example. Suppose you have a variable called age with an initial value of 20. To get the pointer to this variable, you can use the ampersand (&) operator:...

Understanding the Difference Between Primitive Types and Objects in JavaScript

What sets primitive types apart from objects in JavaScript? Let’s take a closer look. First, let’s define what primitive types are: Strings Numbers (Number and BigInt) Booleans (true or false) Undefined Symbol values While null is considered a special primitive type, calling typeof null actually returns 'object', even though it is a primitive type. In JavaScript, anything that is not a primitive type is an object, including functions. Functions can have properties and methods assigned to them....