Short and effective JavaScript & TypeScript snippets for the modern-day developer.
- Over 200 carefully crafted snippets
- Modern JavaScript syntax
- Modern JavaScript APIs (Intl, URL, Navigator...)
- Strategically placed tabstops
- Prefixes created with exact-match in mind
- Auto-generated documentation
Only JavaScript and TypeScript will be supported. Specific frameworks get their own extensions. No bloat.
The following is not mandatory, but could provide a nicer experience. Test them out and decide what works best for you.
Look for it in user settings, or edit the settings.json directly:
"editor.formatOnSave": true,
// Tab complete snippets when their prefix match. Works best when 'quickSuggestions' aren't enabled.
"editor.tabCompletion": "onlySnippets"
Most of the code snippets are without semicolons (;
), except for where it
allows for better tabstop management. Strings use single quotes ('
).
It's highly recommended to use these snippets along with Prettier/ESLint to have your code automatically formatted to your preference.
$1
,$2
,$3
specify cursor locations, in order in which tabstops will be visited$0
denotes the final cursor position- Multiple occurrences of the same tabstop are linked and updated in sync
- Tabstops with default values →
${1:name}
- Tabstops with multiple values →
${1|one,two,three|}
. - Truncated in documentation, for easier viewing →
${1|one,...|}
.
Prefix | Name | Body |
ca |
const assignment |
|
la |
let assignment |
|
cas |
const string assignment |
|
las |
let string assignment |
|
caa |
const array assignment |
|
cao |
const object assignment |
|
dob |
object destructuring |
|
dar |
array destructuring |
|
Prefix | Name | Body |
fn |
function |
|
fna |
async function |
|
nfn |
named arrow function |
|
nfna |
async named arrow function |
|
af |
arrow function |
|
arr |
arrow function arrow |
|
afa |
async arrow function |
|
afb |
arrow function with body |
|
afba |
async arrow function with body |
|
iife |
immediately-invoked function expression |
|
Prefix | Name | Body |
iff |
if statement |
|
ifel |
if/else statement |
|
ifei |
if/else-if statement |
|
el |
else statement |
|
ei |
else if statement |
|
ter |
ternary operator |
|
tera |
ternary expression assignment |
|
sw |
switch |
|
scase |
switch case |
|
tc |
try/catch |
|
tcf |
try/catch/finally |
|
tf |
try/finally |
|
Prefix | Name | Body |
flr |
for loop (range) |
|
rfl |
reverse for loop |
|
fin |
for...in loop |
|
fof |
for...of loop |
|
fofa |
for await...of loop |
|
wl |
while loop |
|
dwl |
do while loop |
|
Prefix | Name | Body |
cs |
class |
|
cse |
class extends |
|
csp |
class proprety |
|
csc |
class with constructor |
|
csec |
class extends with constructor |
|
cst |
class constructor |
|
get |
getter |
|
set |
setter |
|
gs |
getter and setter |
|
met |
method |
|
meta |
async method |
|
Prefix | Name | Body |
aat |
array.at |
|
fe |
Array.forEach() |
|
map |
Array.map() |
|
fmap |
Array.flatMap() |
|
reduce |
Array.reduce() |
|
reduceRight |
Array.reduceRight() |
|
filter |
Array.filter() |
|
find |
Array.find() |
|
findl |
Array.findLast() |
|
findi |
Array.findIndex() |
|
findli |
Array.findLastIndex() |
|
every |
Array.every() |
|
some |
Array.some() |
|
reverse |
Array.reverse() |
|
sort |
Array.sort( |
|
group |
Array.group() |
|
groupMap |
Array.groupToMap() |
|
mapStr |
Array.map() to string |
|
mapNum |
Array.map() to number |
|
mapBool |
Array.map() to boolean |
|
filterTruthy |
Array.filter() truthy |
|
arfr |
Array.from |
|
Prefix | Name | Body |
im |
import from module |
|
imd |
import default |
|
ima |
import as |
|
imf |
import file |
|
imp |
import dynamic |
|
impa |
await import dynamic |
|
imm |
import meta |
|
ex |
export |
|
exd |
export default |
|
exf |
export from |
|
exa |
export all from |
|
exo |
export object |
|
efn |
export function |
|
edfn |
export default function |
|
enfn |
export named arrow function |
|
Prefix | Name | Body |
fet |
fetch |
|
feta |
fetch assignment |
|
npr |
promise |
|
prr |
Promise.resolve |
|
prj |
Promise.reject |
|
then |
promise then() |
|
catc |
promise catch() |
|
thenc |
promise then().catch() |
|
pra |
Promise.all |
|
pras |
Promise.allSettled |
|
pran |
Promise.any |
|
Grouping them all together for now
Prefix | Name | Body |
arr |
array literal |
|
ob |
object literal |
|
tl |
template literal |
|
tle |
template literal operation |
|
ns |
new Set |
|
nm |
new Map |
|
am |
array merge |
|
om |
object merge |
|
or |
OR (||) |
|
and |
AND (&&) |
|
lt |
less than (<) |
|
lte |
less than or equal to (<=) |
|
gt |
greater than (>) |
|
gte |
greater than or equal to (>=) |
|
nc |
nullish coalescing (??) |
|
neq |
strict non-equality (===) |
|
eq |
strict equality (===) |
|
ora |
logical OR assignment (||=) |
|
nca |
nullish coalescing assignment (??=) |
|
plus |
addition |
|
minus |
subtraction |
|
mul |
multiplication |
|
div |
division |
|
mod |
modulo |
|
inc |
addition assignment |
|
sub |
subtraction assignment |
|
mula |
multiplication assignment |
|
diva |
division assignment |
|
col |
colon |
|
Prefix | Name | Body |
oe |
Object.entries |
|
ofe |
Object.fromEntries |
|
ok |
Object.keys |
|
ov |
Object.values |
|
Prefix | Name | Body |
pi |
parse int |
|
pf |
parse float |
|
uniq |
array of unique values |
|
seq |
sequence of 0..n |
|
cp |
copy to clipboard |
|
nurl |
new URL |
|
sp |
url search params |
|
spa |
url search params assignment |
|
spg |
get search param |
|
sps |
set search param |
|
Prefix | Name | Body |
ret |
return |
|
reo |
return object |
|
rei |
return object inline |
|
terr |
throw error |
|
Prefix | Name | Body |
si |
set interval |
|
st |
set timeout |
|
sim |
set immediate |
|
prnt |
process next tick |
|
Prefix | Name | Body |
jsp |
JSON parse |
|
jss |
JSON stringify |
|
jssf |
JSON stringify (formatted) |
|
Prefix | Name | Body |
cl |
console.log |
|
ci |
console.info |
|
cdi |
console.dir |
|
ce |
console.error |
|
cw |
console.warn |
|
ct |
console.time |
|
ctb |
console.table |
|
clr |
console.clear |
|
clm |
console.log message |
|
clo |
console.log object |
|
clc |
console.log clipboard |
|
cll |
console.log (labeled) |
|
cil |
console.info (labeled) |
|
cel |
console.error (labeled) |
|
cwl |
console.warn (labeled) |
|
Prefix | Name | Body |
nd |
new Date() |
|
nds |
new Date() with date string |
|
now |
Date.now() |
|
tls |
Date.toLocaleString() |
|
Prefix | Name | Body |
qs |
query selector |
|
qsa |
query selector all |
|
qsaa |
query selector all as array |
|
ael |
event listener |
|
qsae |
query selector with event listener |
|
gid |
get element by id |
|
Prefix | Name | Body |
req |
require |
|
rqr |
require assignment |
|
mex |
module.exports |
|
Internationalization API
Prefix | Name | Body |
inf |
Intl.NumberFormat |
|
infs |
Intl.NumberFormat style |
|
infc |
Intl.NumberFormat as currency |
|
infp |
Intl.NumberFormat as percentage |
|
infu |
Intl.NumberFormat as unit |
|
idtf |
Intl.DateTimeFormat |
|
idtfs |
Intl.DateTimeFormat with style |
|
Prefix | Name | Body |
aia |
is array |
|
tof |
typeof |
|
tofc |
typeof check |
|
iof |
instanceof |
|
isnil |
is nil |
|
nnil |
is not nil |
|
isnan |
is NaN |
|
nnan |
is not NaN |
|
Prefix | Name | Body |
desc |
describe |
|
cont |
context |
|
it |
test (synchronous) |
|
ita |
test (asynchronous) |
|
itc |
test (callback) |
|
bf |
before test suite |
|
bfe |
before each test |
|
aft |
after test suite |
|
afe |
after each test |
|
Prefix | Name | Body |
wlo |
window.location |
|
wlh |
window.location.href |
|
Prefix | Name | Body |
us |
'use strict' statement |
|
prs |
process.server |
|
prc |
process.client |
|
env |
env variable |
|
envv |
env variable (meta) |
|
Available only where TypeScript is supported
Prefix | Name | Body |
cat |
const assignment (typed) |
|
lat |
let assignment (typed) |
|
caat |
array assignment (typed) |
|
caot |
object assignment (typed) |
|
Prefix | Name | Body |
int |
interface |
|
inte |
interface extends |
|
tp |
type |
|
tpu |
type union |
|
tpi |
type intersection |
|
Prefix | Name | Body |
qst |
query selector (typed) |
|
qsat |
query selector all (typed) |
|
qsaat |
query selector all as array (typed) |
|
gidt |
get element by id (typed) |
|
# ensure Deno is installed
# https://deno.land/manual@v1.29.1/getting_started/installation
# generate .code-snippets and documentation
npm run generate