Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>JavaScript SnippetsNew to Visual Studio Code? Get it now.

JavaScript Snippets

algorizen

|
11,214 installs
| (3) | Free
JavaScript(ES6+) syntax code snippets for VS Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

JavaScript Snippets

VS Code JavaScript Snippets

This extension contains code snippets for JavaScript in ES6 syntax for VS Code editor.

Note

  • Excluding vscode built-in snippets.
  • Excluding the final semicolon ;.
  • Use single quotes('') instead of double quotes("").

Supported languages (file extensions)

  • JavaScript (.js)
  • TypeScript (.ts)
  • JavaScript React (.jsx)
  • TypeScript React (.tsx)
  • Html (.html)
  • Vue (.vue)

Snippets

Below is a list of all available snippets and the triggers of each one. Remember to use tab key.

Miscellaneous

Table
Trigger Content
us 'use strict'
kv key: value
dir console.dir()

Flow Control

Table
Trigger Content
els else {}
eli else if () {}
ter ? :
tryc catch () {}
tryf finally {}
trycf try {} catch () {} finally {}

Functions

Table
Trigger Content
func function name(args) {}
af () => {}
iife ;(() => {})()
afn const name = () => {}
funcg function* name(args) {}

Common Methods

Table
Trigger Content
concat concat()
inc includes()
io indexOf()
la lastIndexOf()
sl slice()
tos toString()

Array

Table
Trigger Content
from Array.from()
isa Array.isArray()
cw copyWithin()
eve every()
fi fill()
filt filter()
find find()
findi findIndex()
flat flat()
flatm flatMap(() => {})
jo join()
map map(() => {})
po pop()
pu push()
red reduce(() => {})
redr reduceRight(() => {})
rev reverse()
shi shift()
som some(() => {})
sor sort(() => {})
sp splice()
tls toLocaleString()
un unshift()

String

Table
Trigger Content
fromch String.fromCharCode()
fromco String.fromCodePoint()
raw String.raw()
chara charAt()
charc charCodeAt()
codep codePointAt()
endsw endsWith()
localec localeCompare()
match match()
matcha matchAll()
norm normalize()
pade padEnd()
pads padStart()
repe repeat()
repl replace()
replaceall replaceAll()
sear search()
split split()
startsw startsWith()
subs substring()
tll toLocaleLowerCase()
tlu toLocaleUpperCase()
tlc toLowerCase()
tou toUpperCase()
trim trim()
trime trimEnd()
trims trimStart()
valueof valueOf()

Object

Table
Trigger Content
ass Object.assign()
crea Object.create()
dp Object.defineProperties()
dp Object.defineProperty()
entri Object.entries()
free Object.freeze()
frome Object.fromEntries()
gopd Object.getOwnPropertyDescriptor()
gopd Object.getOwnPropertyDescriptors()
gopn Object.getOwnPropertyNames()
gops Object.getOwnPropertySymbols()
gpo Object.getPrototypeOf()
is Object.is()
ise Object.isExtensible()
isf Object.isFrozen()
iss Object.isSealed()
keys Object.keys()
pe Object.preventExtensions()
seal Object.seal()
setp Object.setPrototypeOf()
values Object.values()
haso hasOwnProperty()
isp isPrototypeOf()
pi propertyIsEnumerable()
tls toLocaleString()
valueof valueOf()

Collections

Table
Trigger Content
clear clear()
delete delete()
has has()
add add()
get get()
set set()

Classes

Table
Trigger Content
class class name { constructor() {} }
constr constructor() { }
classe class name extends base { constructor() { super() } }
stat static name
sm static name() {}
pt Class.prototype.method = function() {}
gett get property() {}
sett set property(value) {}

Types

Table
Trigger Content
typ typeof source
ins instanceof Object

Promise

Table
Trigger Content
retp return new Promise((resolve, reject) => {})
pro new Promise((resolve, reject) => {})
prot promise.then(() => {})
proc promise.catch(() => {})
prof promise.finally(() => {})
proall Promise.all()
prorace Promise.race()
proallls Promise.allSettled()
proany Promise.any()
rej promise.reject()
res promise.resolve()
asy async
aw await

ES6 Module

Table
Trigger Content
exp export member
expd export default member
expf export function name(args) {}
expaf export const name = () => {}
imp import name from 'module'
impd import * as name from 'module'

Node.js

Table
Trigger Content
moe module.exports = name
moeo module.exports = {}
req require('module')
ctx (ctx, next) => {}

Timer

Table
Trigger Content
setim setImmediate(() => {})
nt process.nextTick(() => {})

TypeScript

Table
Trigger Content
iterable Iterable statement
inter interface shapes {}
type type primitives {}
enum enum direction {}
classi class name implements interface {}
impt import type { \* } from 'module'
expt export type ${0:member}
expi export interface shapes {}
t <T>
te <T extends base>
part Partial<Type>
requ Required<Type>
reado Readonly<Type>
rec Record<Keys, Type>
pick Pick<Type, Keys>
omit Omit<Type, Keys>
exclude Exclude<Type, ExcludedUnion>
extract Extract<Type, Union>
nonn NonNullable<Type>
para Parameters<Type>
constr ConstructorParameters<Type>
rett ReturnType<Type>
insta InstanceType<Type>
thispar ThisParameterType<Type>
omitt OmitThisParameter<Type>
thist ThisType<Type>

Vue

Table
Trigger Content
vue Vue SFC
script Vue <script> Block
template Vue <template> Block
style Vue <style> Block
  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2022 Microsoft