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
| // https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript | |
| type MyRecord = Record<string, number> | |
| type MyRecord = { [key: string]: number } | |
| // TODO improved enums! | |
| const OPERATORS = [ '*', '/', '+', '-' ] as const | |
| type Operator = typeof OPERATORS[number] | |
| type Color = "primary" | "secondary" | (string & {}); |
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
| // https://code.claude.com/docs/en/settings | |
| { | |
| "$schema": "https://json.schemastore.org/claude-code-settings.json", | |
| "permissions": { | |
| "allow": [ | |
| "Bash(npm run lint)", | |
| "Bash(npm run test *)", | |
| "Read(~/.zshrc)" | |
| ], | |
| "deny": [ |
- Links are introduced in suggested order of reading
- Intended target: someone knowing to program but not in JavaScript
- Why investing in JavaScript? BLOG POST IN PROGRESS
- A re-introduction to JavaScript (JS tutorial) https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
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
| ## https://developers.google.com/edu/python | |
| # ternary | |
| a if x else b | |
| ## strings | |
| ## https://developers.google.com/edu/python/strings | |
| s = 'hi' | |
| print(s[1]) ## i | |
| print(len(s)) ## 2 |
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
| // null coalescings https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing | |
| foo = foo ?? 42 | |
| foo ??= 42 | |
| // optional chaining https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining | |
| dog?.name | |
| dog?.[name] | |
| hello?.(target) |
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
| // https://react.dev/learn/typescript | |
| import React from 'react' | |
| // really? or import * as React from 'react' ?? https://github.com/facebook/react/pull/18102 ALSO https://www.typescriptlang.org/tsconfig/#allowSyntheticDefaultImports | |
| // or not even need to import React? https://parceljs.org/recipes/react/#jsx | |
| import React, { Component } from 'react' | |
| // (from .d.ts) | |
| type ReactNode = | |
| | ReactElement |
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
| ///////////////////////////////////////////////// | |
| // __dirname, __filename | |
| // https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#pure-esm-package | |
| // https://nodejs.org/api/globals.html | |
| import * as path from 'node:path' | |
| import { fileURLToPath } from 'node:url' | |
| const __dirname = path.dirname(fileURLToPath(import.meta.url)) |
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
| /////// REDUCE /////// | |
| res = iter.reduce((acc, val) => { | |
| return acc + val | |
| }, 0) | |
| err = decorators.reduce((err, decorator) => { | |
| return decorator(err) | |
| }, err) | |
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
| import EventEmitter from 'emittery' | |
| const EMITTER_EVT = 'change' | |
| const emitter = new EventEmitter<{ [EMITTER_EVT]: string }>() | |
| emitter.emit(EMITTER_EVT, `[in-mem]`) | |
| const unbind = emitter.on(EMITTER_EVT, (src: string) => { ... }) |
NewerOlder