How to Create a List in Python?

python create list

When I first started coding in Python, lists were the very first data structure I used. I realized how powerful they are. A Python list can hold numbers, strings, or even a mix of both. It’s like having a flexible container where you can store and organize your data. Over the years, I’ve used lists … Read more >>

How to Use Shallow Copy vs. Deep Copy in Python

Shallow Copy vs. Deep Copy in Python

I have run into many situations where I needed to duplicate data without affecting the original. It sounds simple enough to just use the assignment operator, but that is often where the trouble starts for many developers. I remember working on a logistics dashboard for a shipping company in New York, and we had a … Read more >>

What does “TypeError: is not a function” mean in TypeScript?

What does “TypeError is not a function” mean in TypeScript

In TypeScript, “TypeError: is not a function” is a runtime JavaScript error that appears when you try to call something with () that is not actually a function. The value might be a string, an object, undefined, null, or some other type that cannot be called. Most of the time, this happens because the variable you are calling does … Read more >>

TypeScript Key Value Pair: Record, Map and Typed Pairs

TypeScript key value pair: Command Prompt output of a Map storing ZIP codes and city names

A TypeScript key value pair is usually stored in a plain object typed with Record<K, V> or an index signature, or in a Map<K, V> when keys change often or aren’t strings. Both give you typed lookups by key: My test machine ran TypeScript 7.0.2 and Node.js v22.22.2 with strict mode on, so what you … Read more >>

How to Get the First Element from a TypeScript Dictionary

Get first element from a TypeScript dictionary: Command Prompt output of a Map's first entry with iterator next()

To get the first element from a TypeScript dictionary, read index 0 of Object.entries() for a plain object or Record, and call .entries().next().value for a Map. Both give back undefined when the dictionary is empty: I ran all five examples with TypeScript 7.0.2 and Node.js v22.22.2 (strict mode on), so the outputs you see are … Read more >>

How to Get Enum Key by Value in TypeScript

Get Enum Key by Value in TypeScript

While building an e-commerce admin dashboard in TypeScript, you define an enum called ProductCategory to manage all category types consistently across your app. This enum helps when filtering, tagging, or assigning categories to products during development. However, fetching product data from an external API returns only the category value (not the enum key). So, in … Read more >>

How to Split a String by Comma in TypeScript?

Split a String by Comma in TypeScript

In this tutorial, I will explain how to split a string by comma in TypeScript. If you’re a developer working with TypeScript, you might often need to handle strings that contain lists of items separated by commas. You need to know how to split a string by commas in cases such as processing CSV data, … Read more >>

How to Split a String by Regex in TypeScript

Split string by regex in TypeScript: Command Prompt output of camelCase and sentence splits with lookahead and lookbehind

You split a string by regex in TypeScript by passing a RegExp to split() instead of a string. Every match becomes a cut point, and you get back a string[]: Each snippet here was compiled in strict mode with TypeScript 7.0.2 and Node.js v22.22.2. I pasted the console output straight from those runs. How split() … Read more >>

How to Split a String and Get the Last Element in TypeScript

Split a string and get the last element in TypeScript: Command Prompt output of split with at(-1)

When you need to split a string and get the last element in TypeScript, call split() and read the final item with at(-1). Add ?? “” because TypeScript types that item as string | undefined: I tested all of this on TypeScript 7.0.2 and Node.js v22.22.2, strict mode on. What you see under each example … Read more >>