Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Follow publication

Member-only story

LINQ vs TypeScript: Method Equivalents at a Glance

Daniel Rusnok
Level Up Coding
Published in
5 min read3 days ago

generated by ChatGPT

Not a member? Read for free here.

Introduction

After years of working as a .NET backend developer, I transitioned into frontend development with TypeScript and quickly realized something: While LINQ made working with collections in C# feel elegant and intuitive, doing the same in TypeScript wasn’t always straightforward. I often knew exactly what I wanted to do — filter, transform, group — but not how to do it in TypeScript.

This article is a practical guide for developers like me who are fluent in LINQ and want to quickly find the TypeScript equivalents of common LINQ methods. If you’re short on time, feel free to jump straight to the summary table at the end. But if you’d like to scroll through and pick up some extra tips and caveats along the way, you’re more than welcome.

This post is a follow-up to my previous article, where I shared my experience of moving from backend architecture to frontend development — what surprised me, what I missed, and what I had to relearn. This time, we’re diving straight into the code.

Select → map

C# (LINQ)

var names = people.Select(p => p.Name);
var doubled = new[] { 1, 2, 3 }.Select(n => n * 2);

TypeScript

const names = people.map(p => p.name);
const doubled = [1, 2, 3].map(n => n * 2);

Notes

  • Select works on any IEnumerable<T>, while map() only works on arrays.
  • In JavaScript, watch out for null or undefined—calling map() on them throws an error.
  • Both methods return a new collection with the same number of items.

Where → filter

C# (LINQ)

var active = users.Where(u => u.IsActive);

TypeScript

const active = users.filter(u => u.isActive);

Notes

  • Where and filter both return only items that match the condition.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Written by Daniel Rusnok

Full-stack dev with a frontend focus. React, TypeScript, .NET. Clean code enthusiast.

Write a response