Created
October 30, 2025 22:58
-
-
Save tunnckoCore/9377e880724f4bd76e08688ea19e6337 to your computer and use it in GitHub Desktop.
wut?!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const foo = [ | |
| { name: "Alice", age: 25 }, | |
| { name: "Bob", age: 30 }, | |
| { name: "Charlie", age: 35 }, | |
| { name: "David", age: 40 }, | |
| ]; | |
| export type Item = { name: string; age: number }; | |
| export async function foobar(collection: Item[]) { | |
| const items = [...collection] as (Item & { glitched: boolean })[]; | |
| items.forEach((item, index) => { | |
| const itemNumber = index; | |
| if (itemNumber >= 1 && itemNumber <= 3) { | |
| item.glitched = true; | |
| } else { | |
| item.glitched = false; | |
| } | |
| }); | |
| return items; | |
| } | |
| const newFoo = await foobar([...foo]); | |
| console.log("original foo:", foo); | |
| console.log("new foo:", newFoo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment