Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
class User { id: number; name: string; email: string; constructor(id: number, name: string, email: string) { this.id = id; this.name = name; this.email = email; } static getById(id: number, users: User[]): User | undefined { return users.find(user => user.id === id); } } const users = [ new User(1, 'Alice', 'alice@example.com'), new User(2, 'Bob', 'bob@example.com'), new User(3, 'Charlie', 'charlie@example.com'), ]; const user = User.getById(2, users); if (user) { console.log(user.name); } else { console.log('User not found'); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)