How to Use Enums in JavaScript? Defining a Custom Object

If you come from a Typescript background or any other languages like C++, Python, etc., you must have come across Enums. Although “enum” is a reserved keyword in Javascript, Enums don’t really exist in Javascript, but you can “kind of” create them yourself, as you will learn in this post. An enum is a short … Read more

(Solved) Cannot Convert Undefined or Null to Object in JS

The error “TypeError: Cannot convert undefined or null to object” happens when JavaScript attempts to convert null and undefined to an object. Below you can see examples of when this error occurs. In the previous example, notice how the Object.assign() , Object.keys() , and Object.values() methods expect a parameter o equivalent to any JavaScript object … Read more

(Solved) TypeScript Array.find() possibly ‘undefined’

Errors like “TS2532: Object is possible ‘undefined’” can happen after defining the value of a variable by using the array.find() method. Here are the possible reasons why thearray.find() method returns undefined: The predicate parameter or callback function passed to the array.find() doesn’t explicitly use the return keyword to return a truthy value. The predicate parameter … Read more

TypeScript | A Practical Guide to Use Extends in TypeScript

With the introduction of ECMAScript 2015, commonly known as ES6, you can implement object-oriented programming as a class-based approach in JavaScript/TypeScript. Before that, JavaScript developers would use the prototype-based approach to implement the object-oriented pattern in their code. Similar to object-oriented languages like Java and C#, now TypeScript developers can use various object-oriented features like interfaces, inheritance, … Read more

How to Print a Raw Pointer in Rust?

The other day I wrote an article about the dereference unary operator (*) and I needed a way to explain the unary operator by first explaining about pointers in Rust, which are the memory address location of, for example, a variable. However, I didn’t know how to print the pointer of a variable, without displaying … Read more

JavaScript Higher-Order Functions: A Guide with Examples

Functions are one of the fundamental building blocks in Javascript. A function is a set of statements that perform a task or calculate a value. They come in handy as they simplify our program’s structure, readability, and reusability by abstracting the implementation of a particular algorithm. As a functional language, Javascript supports the concept of … Read more

Rust | (Solved) “Missing type for `const` or `static`”

Have you come across the following error error: missing type for const item in Rust? Chances are, you defined a constant value like this: At first, this doesn’t seem to be an error as Rust is capable of implicitly determine the data type of other non-constant scoped variables (let ) like the one you see … Read more