Code snippets for JavaScript in ES3/5/6+ syntax;
Download this extension from the Visual Studio Code Marketplace.
- Declarations
- Statement
- Function
- Array
- Object
- String
- Number
- Regexp
- chore
- Module
- Class
- Promise
- Generator Iterator
- Async
- Symbol
- Maps & Sets
- Error
- Event
- AJAX
- Proxy & Reflection
- Math
- DOM
- BOM
- Console
- CommonJS/Node.js
- BDD Testing (Mocha, Jasmine, etc.)
- JavaScript (
.js) - TypeScript (
.ts) - JavaScript React (
.jsx) - TypeScript React (
.tsx) - Html (
.html) - Vue (
.vue)
Note: All the snippets include the final semicolon ;
| Prefix | Body | Description |
|---|---|---|
usm β |
'use strict'; |
use strict mode |
c β |
const name = value; |
|
co/lo/vo β |
const/let/var feature = {}; |
|
ca/la/va β |
const/let/var feature = []; |
|
cs/ls/vs β |
const/let/var feature = ''; |
|
cdo β |
const {} = ; |
const destructing object |
cda β |
const [] = ; |
const destructing array |
l β |
let name = value; |
|
ldo β |
let {} = ; |
|
lda β |
let [] = ; |
|
v β |
var name = value; |
|
vdo β |
var {} = ; |
|
vda β |
var [] = ; |
|
dp β |
{}: parameter |
destructuring parameter |
po β |
property: { property, }, |
property object |
pa β |
property: [item], |
property array |
ps β |
property: 'value', |
property string |
| Prefix | Body | Description |
|---|---|---|
if β |
if (condition) { } |
|
ife β |
if (condition) { } else { } |
|
ei β |
else if (condition) { } |
|
el β |
else { } |
|
swi β |
switch () { case : statements; break; default: statements; break;} |
|
cas β |
case value: statements; break; |
|
fin β |
for (const key in object) { if (object.hasOwnProperty(key)) { }} |
for-in |
fof β |
for (const item of object) { } |
for-of |
fl/fo/for β |
for (const index = 0, length = iterable.length; index < length; index += 1) { } |
|
flr/forr β |
for (const length = iterable.length - 1; length >= 0; length -= 1) { } |
for loop iterable(reverse) |
wh β |
while (condition) { } |
|
whi β |
let iterableIndex = array.lengthwhile (iterableIndexIndex--) { } |
| Prefix | Body | Description |
|---|---|---|
fn β |
function name(param) { } |
function |
fna β |
function(param) { } |
function anonymous |
vfn β |
var name = function (param) { } |
|
lfn β |
let name = function (param) { } |
|
cfn β |
const name = function (param) { } |
|
fnp β |
name: function (param) { } |
function as property |
fnapply β |
method.apply(context, [param]); |
function.apply |
fncall β |
method.call(context, param); |
function.call |
fnbind β |
method.bind(this); |
function.bind |
af β |
(param) => { } |
arrow function |
afr β |
(param) => { return } |
arrow function with return |
afd β |
({param}) => statement |
arrow function with destructuring |
laf β |
let name = (param) => { } |
|
caf β |
const name = (param) => { } |
|
iif β |
;((param) => { })() |
|
iife β |
;(function (param) { })() |
|
nt β |
if (typeof new.target === 'undefined') { throw new Error('Fn() must be called with new');}" ]} |
new.target |
Arr.<static_method> or arr.<instance_method>
| Prefix | Body | Description |
|---|---|---|
ar β |
const arr = []; |
|
arl β |
iterable.length; |
|
isa β |
Array.isArray(value) |
|
arfr β |
Array.from(arrayLike); |
|
arfr β |
Array.from(arrayLike, (item) => { }); |
|
arof β |
Array.of(elementN); |
|
ara β |
iterable.at(index); |
array.at |
arc β |
iterable.concat(valueN); |
array.concat |
arcw β |
iterable.copyWithin(target, start, end); |
array.copyWithin |
are β |
iterable.entries(); |
array.entries |
arev β |
iterable.every((element) => { }); |
array.every |
arfill β |
iterable.fill(value, start, end); |
|
arf β |
iterable.filter((element) => { }); |
|
arfi β |
iterable.find((element) => { }); |
|
arfin β |
iterable.findIndex((element) => { }) |
|
arflat β |
iterable.flat(); |
|
arflatMap β |
iterable.flatMap((value) => value); |
|
fea β |
iterable.forEach((currentValue) => { }); |
forEach callback with arrow function |
feai β |
iterable.forEach((currentValue, index) => { }); |
|
fe β |
iterable.forEach(function(currentValue) { }); |
|
fei β |
iterable.forEach(function(currentValue, index) { }); |
|
ari β |
iterable.includes(valueToFind) |
|
ario β |
iterable.indexOf(searchElement) |
|
arj β |
iterable.join(separator); |
|
ark β |
iterable.keys(); |
|
arlio β |
iterable.lastIndexOf(searchElement) |
|
map β |
iterable.map((currentValue) => { }); |
|
arp β |
iterable.pop(); |
|
arj β |
iterable.push(elementN); |
|
arr β |
iterable.reduce((previousValue, currentValue) => { }); |
|
arrr β |
iterable.reduceRight((accumulator, currentValue) => { }); |
|
arre β |
iterable.reverse(); |
|
ars β |
iterable.shift(); |
|
arsl β |
iterable.slice(begin, end); |
|
arso β |
iterable.some((element) => { }); |
|
arsor β |
iterable.sort((firstEl, secondEl) => { }); |
|
arsp β |
iterable.splice(start, deleteCount, item); |
|
aru β |
iterable.unshift(elementN); |
|
arv β |
iterable.values(); |
|
arr.@@iterator |
Array.prototype[@@iterator]() |
|
arr.@@species |
get Array[@@species] |
|
seq β |
[...Array(length).keys()] |
Obj.<static_method> or obj.<instance_method>
| Prefix | Body | Description |
|---|---|---|
ol β |
{ key: value } |
|
kv β |
key: value, |
|
om β |
method(param) { }, |
object method() |
oset β |
set property(value) { }, |
object set |
oget β |
get property() { }, |
object get |
oam β |
method: (param) => { }, |
object arrow method statements |
oame β |
method: (param) => $3, |
object arrow method expression |
oasm β |
async method(param) { }, |
object async method() |
oa β |
Object.assign(target, source); |
|
oc β |
Object.create(obj); |
|
odp β |
Object.defineProperty(dest, 'propertyName', { value: undefined, configurable: false, enumerable: false, writable: false}) |
Object.defineProperty(data descriptors) |
odpa β |
Object.defineProperty(dest, 'propertyName', { get() { return value; }, set(newValue) { value = newValue; }, enumerable: false, configurable: false}) |
Object.defineProperty(accessor descriptors) |
odps β |
Object.defineProperties(dest, { propertyName: { configurable: false, enumerable: false, value: undefined, writable: false }, propertyName: { get() { return value; }, set(newValue) { value = newValue; }, enumerable: false, configurable: false }}); |
Object.defineProperties |
oe β |
Object.entries(obj); |
|
of β |
Object.freeze(obj); |
|
ofe β |
Object.fromEntries(iterable); |
|
ogopd β |
Object.getOwnPropertyDescriptor(obj, 'propertyName'); |
Object.getOwnPropertyDescriptor |
ogopds β |
Object.getOwnPropertyDescriptors(obj); |
Object.getOwnPropertyDescriptors |
ogopn β |
Object.getOwnPropertyNames(obj); |
Object.getOwnPropertyNames |
ogops β |
Object.getOwnPropertySymbols(obj); |
Object.getOwnPropertySymbols |
ogpo β |
Object.getPrototypeOf(obj); |
Object.getPrototypeOf |
oi β |
Object.is(value1, value2); |
|
oie β |
Object.isExtensible(obj) |
|
oif β |
Object.isFrozen(obj) |
|
ois β |
Object.isSealed(obj) |
|
ok β |
Object.keys(obj); |
|
ope β |
Object.preventExtensions(obj); |
|
os β |
Object.seal(obj); |
|
ospo β |
Object.setPrototypeOf(obj, prototype); |
Object.setPrototypeOf |
ov β |
Object.values(obj); |
|
hop β |
obj.hasOwnProperty(propertyName) |
hasOwnProperty |
ipo β |
prototypeObj.isPrototypeOf(object) |
isPrototypeOf |
pie β |
obj.propertyIsEnumerable(propertyName) |
propertyIsEnumerable |
tls β |
objects.toLocaleString(); |
toLocaleString |
ts β |
objects.toString(); |
toString |
vo β |
objects.valueOf(); |
valueOf |
Str.<static_method> or str.<instance_method>
| Prefix | Body | Description |
|---|---|---|
tl β |
${expression} |
Template literals |
sfcc β |
String.fromCharCode(numN) |
String.fromCharCode |
sfcp β |
String.fromCodePoint(numN) |
|
sr β |
String.raw |
|
sca β |
str.charAt(index) |
|
scca β |
str.charCodeAt(index) |
|
scpa β |
str.codePointAt(position) |
|
sc β |
str.concat(stringN) |
|
sew β |
str.endsWith(searchString) |
|
sin β |
str.includes(searchString) |
|
sio β |
str.indexOf(searchValue) |
|
slio β |
str.lastIndexOf(searchValue) |
|
slc β |
str.localeCompare(compareString) |
|
sm β |
str.match(regexp) |
|
sma β |
str.matchAll(regexp) |
|
sn β |
str.normalize('NFC') |
|
spe β |
str.padEnd(targetLength, padString) |
|
sps β |
str.padStart(targetLength, padString) |
|
sr β |
str.repeat(count) |
|
sre β |
str.replace(regexp, newSubStr) |
|
ss β |
str.search(regexp) |
|
ssl β |
str.slice(beginIndex, endIndex) |
|
ssp β |
str.split(separator) |
|
ssw β |
str.startsWith(searchString, position) |
|
sss β |
str.substring(indexStart, indexEnd) |
|
stllc β |
str.toLocaleLowerCase() |
|
stluc β |
str.toLocaleUpperCase() |
|
stlc β |
str.toLowerCase() |
|
stuc β |
str.toUpperCase() |
|
str β |
str.trim() |
|
ste β |
str.trimEnd() //trimRight() |
|
sts β |
str.trimStart() //trimLeft() |
|
ssi β |
str[Symbol.iterator] |
Num.<static_method> or num.<instance_method>
| Prefix | Body |
|---|---|
ne β |
Number.EPSILON |
nmasi β |
Number.MAX_SAFE_INTEGER |
nmav β |
Number.MAX_VALUE |
nmisi β |
Number.MIN_SAFE_INTEGER |
nmav β |
Number.MIN_VALUE |
nni β |
Number.NEGATIVE_INFINITY |
nn β |
Number.NaN |
npi β |
Number.POSITIVE_INFINITY |
nif β |
Number.isFinite(value) |
nii β |
Number.isInteger(value) |
nin β |
Number.isNaN(value) |
nisi β |
Number.isSafeInteger(value) |
npf β |
Number.parseFloat(string) |
npi β |
Number.parseInt(string) |
nte β |
number.toExponential() |
ntf β |
number.toFixed() |
ntp β |
number.toPrecision() |
re.<method>
| Prefix | Body | Description |
|---|---|---|
re β |
let regex = RegExp('pattern'); |
RegExp |
rep β |
let regex = /pattern/; |
RegExp pattern |
ree β |
let regex = RegExp('pattern');let result = regex.exec(str); |
|
ret β |
let regex = RegExp('pattern');let result = regex.test(str); |
|
re.@@species β |
get RegExp[@@species] |
|
re.@@match β |
RegExp.prototype[@@match]() |
|
re.@@matchAll β |
RegExp.prototype[@@matchAll]() |
|
re.@@replace β |
RegExp.prototype[@@replace]() |
|
re.@@search β |
RegExp.prototype[@@search]() |
|
re.@@split β |
RegExp.prototype[@@split]() |
| Prefix | Body | Description |
|---|---|---|
to β |
typeof operand === 'undefined' |
typeof |
tou β |
typeof operand === 'undefined' |
typeof Undefined |
too β |
typeof operand === 'object' |
typeof Null |
tob β |
typeof operand === 'boolean' |
typeof Boolean |
ton β |
typeof operand === 'number' |
typeof Number |
tob β |
typeof operand === 'bigint' |
typeof BigInt |
tos β |
typeof operand === 'string' |
typeof String |
tos β |
typeof operand === 'symbol' |
typeof Symbol |
tof β |
typeof operand === 'function' |
typeof Function |
too β |
typeof operand === 'object' |
typeof Any other object |
io β |
object instanceof 'constructor' |
instanceof |
jp β |
JSON.parse(obj); |
|
js β |
JSON.stringify(obj); |
|
tc β |
try { } catch (err) { } |
|
tcf β |
try { } catch (err) { } finally { } |
|
tf β |
try { } finally { } |
|
r β |
return ; |
|
rn β |
return null; |
|
rt β |
return this; |
|
ro β |
return { }; |
|
ternary β |
? : ; |
|
de/bug β |
debugger; |
|
eu β |
encodeURI(URI) |
encodeURI |
du β |
decodeURI(encodedURI) |
decodeURI |
euc β |
encodeURIComponent(str) |
encodeURIComponent |
duc β |
decodeURIComponent(encodedURI) |
decodeURIComponent |
| Prefix | Body | Description |
|---|---|---|
im β |
import { moduleName } from 'module'; |
import |
imd β |
import moduleName from 'module'; |
import default export |
imas β |
import { originalName as alias } from 'module'; |
import as renamed exports |
imall β |
import * as alias from 'module'; |
import all module as alias |
imn β |
import 'module'; |
import without module name |
ex β |
export { feature }; |
export |
exas β |
export { variable as feature }; |
export as renaming |
exc β |
export const name = value; |
|
exfn β |
export function name (){ } |
export function |
exaf β |
export const name = (param) => { }; |
export named arrow function |
exafe β |
export const name = (param) => $3; |
export named arrow function |
exd β |
export default expression; |
export default |
exdas β |
export { name as default }; |
|
exdc β |
export default class className { constructor (param) { } } |
|
exdce β |
export default class className extends baseClassName { constructor (param) { super(); } } |
|
exdaf β |
export default (param) => { } |
|
exdafe β |
export default (param) => $3 |
|
exdfn β |
export default function name (param) { } |
|
exfr β |
export {default} from otherModule; |
export from |
exallo β |
export * from otherModule; |
export all from other module |
| Prefix | Body | Description |
|---|---|---|
cl β |
class ClassName { constructor (param) { } } |
class |
cle β |
class ClassName extends BaseClassName { constructor (param) { super(); } } |
class extends |
clc/cons β |
constructor(param) { } |
class constructor |
p/clp β |
property = value; |
class property |
m/clm β |
method (param) { } |
class method |
clsm β |
static methodName(param) { return; } |
class static method() |
clsp β |
static property = value; |
class static property |
clpm β |
#methodName(param) { return ; } |
class private method() |
clpp β |
#property = value; |
class private property |
clspm β |
static #methodName(param) { return ; } |
class static private method() |
clspp β |
static #property = value; |
class static private property |
clgm β |
*methodName(params) { yield ; } |
class generator method() |
get β |
get propertyName () { return this.element; } |
get propertyName |
set β |
set propertyName (value) { this.element = value; } |
set propertyName |
gs β |
get propertyName () { return this.element; } set propertyName (value) { this.element = value; } |
getter and setter |
asm β |
async method(param) { } |
async method |
pc/protoc β |
var Constructor = function(param) { }; |
prototype constructor |
pm/protom β |
Constructor.prototype.method = function (param) { }; |
prototype method |
| Prefix | Body | Description |
|---|---|---|
pr β |
const promise = new Promise((resolve, reject) => { });promise.then(result => { }).catch(error => { }); |
new Promise |
pa β |
const results = await Promise.all([promises]); |
Promise.all |
pan β |
const result = await Promise.any([promises]); |
Promise.any |
pas β |
const results = await Promise.allSettled([promises]); |
Promise.allSettled |
pra β |
const result = await Promise.race([promises]); |
Promise.race |
prj β |
Promise.reject(value); |
Promise.reject |
prs β |
Promise.resolve(value); |
Promise.resolve |
rj β |
reject(err); |
reject |
rs β |
resolve(value); |
resolve |
pc β |
promise.catch(error => { }); |
promise.catch |
pf β |
promise.finally(() => { }); |
promise.finally |
pt β |
promise.then(result => { }) |
promise.then() |
ptc β |
promise.then(result => { }).catch(error => { }); |
promise.then().catch() |
ptcf β |
promise.then(result => { }).catch(error => { }).finally(() => { }); |
promise.then().catch().finally() |
rp β |
return new Promise((resolve, reject) => { }) |
| Prefix | Body | Description |
|---|---|---|
cy β |
const name = yield value; |
|
ly β |
let name = yield value; |
|
gf β |
function* name(param) { yield expression;} |
generator function |
gm β |
*generator(param) { }, |
generator method |
asgm β |
async *generator(param) { }, |
generator method |
y β |
yield expression; |
|
yg β |
yield* expression(); |
| Prefix | Body | Description |
|---|---|---|
caw β |
const result = await promise; |
const awaited |
asfn β |
async function name (param) { const result = await promise; return result;}name().then(result => { }); |
async function named |
asfna β |
async function (param) { } |
async function anonymous |
asgfn β |
async function* name (param) { } |
async generator function named |
asgfna β |
async function* (param) { } |
async generator function anonymous |
asaf β |
async (param) => { } |
async arrow function |
aw β |
await promise |
|
awpa β |
await Promise.all(value) |
|
awpam β |
await Promise.all(array.map((value) => { })) |
| Prefix | Body | Description |
|---|---|---|
| csy β | const symObj = Symbol(); |
|
| symf β | Symbol.for('key'); |
|
| symk β | Symbol.keyFor('symObj'); |
map.<method>weakmap.<method>set.<method>weakset.<method>
| Prefix | Body | Description |
|---|---|---|
cm/map β |
const resourceMap = new Map(); |
|
cs/set β |
const resourceSet = new Set(); |
|
cwm/wm β |
const resourceWeakMap = new WeakMap(); |
|
cws/ws β |
const resourceWeakSet = new WeakSet(); |
|
map.size |
||
map.clear() |
||
map.delete() |
||
map.forEach() |
||
map.get() |
||
map.has() |
||
map.set() |
||
map.entries() |
||
map.keys() |
||
map.values() |
||
weakmap.delete() |
||
weakmap.get() |
||
weakmap.has() |
||
weakmap.set() |
||
set.size |
||
set.add() |
||
set.clear() |
||
set.delete() |
||
set.forEach() |
||
set.has() |
||
set.entries() |
||
set.values() |
||
weakset.add() |
||
weakset.delete() |
||
weakset.has() |
throw.<Type>
| Prefix | Body | Description |
|---|---|---|
tn β |
throw new Error('message') |
|
tne β |
throw new EvalError('message') |
|
tnr β |
throw new RangeError('message') |
|
tnre β |
throw new ReferenceError('message') |
|
tns β |
throw new SyntaxError('message') |
|
tnt β |
throw new TypeError('message') |
|
tnu β |
throw new URIError('message') |
| Prefix | Body | Description |
|---|---|---|
ael β |
document.addEventListener('type', event => { }); |
addEventListener arrow function |
aelfn β |
document.addEventListener('type', function (event) { }); |
addEventListener |
rel β |
document.removeEventListener('event', listener); |
removeEventListener |
eps β |
event.preventDefault();event.stopPropagation();return false; |
event preventDefault and stopPropagation |
epd β |
event.preventDefault(); |
event preventDefault |
esp β |
event.stopPropagation(); |
event stopPropagation |
dev β |
const cancelled = !target.dispatchEvent(event); |
|
click β |
document.addEventListener('click', () => { }); |
|
keydown β |
document.addEventListener('keydown', event => { }); |
|
load β |
window.addEventListener('load', () => { }); |
|
ready β |
window.addEventListener('DOMContentLoaded', () => { }); |
| Prefix | Body | Description |
|---|---|---|
xhr β |
XMLHttpRequest | |
fetch β |
fetch | |
fetchget/fg β |
fetch get | |
fetchpost/fp β |
fetch post |
proxy.<method>
| Prefix | Body | Description |
|---|---|---|
proxy.set β |
Validating Properties Using the set Trap |
|
proxy.get β |
Object Shape Validation Using the get Trap |
|
proxy.has β |
Hiding Property Existence Using the has Trap |
|
proxy.delete β |
Preventing Property Deletion with the deleteProperty Trap | |
proxy.prototype β |
Prototype Proxy Traps | |
proxy.extensibility β |
Object Extensibility Traps | |
proxy.property β |
Property Descriptor Traps | |
proxy.ownKeys β |
The ownKeys Trap |
|
proxy.function β |
Function Proxies with the apply and construct Traps |
|
proxy.revocable β |
Revocable Proxies |
| Prefix | Body | Description |
|---|---|---|
mr β |
Math.random() |
|
mro β |
Math.round() |
20.49 β 20, 20.5 β 21 |
mc β |
Math.ceil() |
7.004 β 8, -7.004 β -7 |
mf β |
Math.floor() |
5.95 β 5, -5.05 β -6 |
mtr β |
Math.trunc() |
5.05 β 5, -0.123 β -0 |
dom.<method> or dom.<property>
| Prefix | Body |
|---|---|
dom.createDocumentFragment β |
document.createDocumentFragment(); |
dom.createElement β |
document.createElement(elem); |
dom.createTextNode β |
document.createTextNode(data); |
dom.getElementById β |
document.getElementById('id'); |
dom.getElementsByClassName β |
document.getElementsByClassName('className'); |
dom.getElementsByTagName β |
document.getElementsByTagName('tagName'); |
dom.querySelector β |
document.querySelector('selector'); |
dom.querySelectorAll β |
document.querySelectorAll('selector'); |
dom.childNodes β |
const nodeList = node.childNodes; |
dom.parentElement β |
const parentElement = node.parentElement; |
dom.parentNode β |
const parentNode = node.parentNode; |
dom.firstChild β |
const childNode = node.firstChild; |
dom.lastChild β |
const childNode = node.lastChild; |
dom.previousSibling β |
const previousNode = node.previousSibling; |
dom.nextSibling β |
const nextNode = node.nextSibling; |
dom.textContent β |
element.textContent = 'content'; |
dom.previousElementSibling β |
const prevNode = NonDocumentTypeChildNode.previousElementSibling; |
dom.nextElementSibling β |
const nextNode = NonDocumentTypeChildNode.nextElementSibling; |
dom.closest β |
const closestElement = targetElement.closest('selectorString'); |
dom.insertBefore β |
node.insertBefore(newNode, referenceNode); |
dom.appendChild β |
node.appendChild(element); |
dom.cloneNode β |
const newClone = node.cloneNode(true); |
dom.getRootNode β |
const root = node.getRootNode(true); |
dom.compareDocumentPosition β |
const compareMask = node.compareDocumentPosition(otherNode); |
dom.contains β |
node.contains(otherNode); |
dom.removeChild β |
node.removeChild(child); |
dom.replaceChild β |
parentNode.replaceChild(newChild, oldChild); |
dom.hasChildNodes β |
node.hasChildNodes() |
dom.firstElementChild β |
const element = parentNode.firstElementChild; |
dom.lastElementChild β |
const element = parentNode.lastElementChild; |
dom.childElementCount β |
const count = parentNode.childElementCount; |
dom.children β |
const children = parentNode.children; |
dom.append β |
parentNode.append(Nodes/DOMStrings); |
dom.prepend β |
parentNode.prepend(Nodes/DOMStrings); |
dom.before β |
childNode.before(Nodes/DOMStrings); |
dom.after β |
childNode.after(Nodes/DOMStrings); |
dom.remove β |
childNode.remove(); |
dom.replaceWith β |
childNode.replaceWith(Node/DOMString); |
dom.before.html β |
element.insertAdjacentHTML('beforebegin', 'DOMString'); |
dom.after.html β |
element.insertAdjacentHTML('afterend', 'DOMString'); |
dom.prepend.html β |
element.insertAdjacentHTML('afterbegin', 'DOMString'); |
dom.append.html β |
element.insertAdjacentHTML('beforeend', 'DOMString'); |
dom.before.element β |
element.insertAdjacentElement('beforebegin', element); |
dom.after.element β |
element.insertAdjacentElement('afterend', element); |
dom.prepend.element β |
element.insertAdjacentElement('afterbegin', element); |
dom.append.element β |
element.insertAdjacentElement('beforeend', element); |
dom.before.text β |
element.insertAdjacentText('beforebegin', value); |
dom.after.text β |
element.insertAdjacentText('afterend', value); |
dom.prepend.text β |
element.insertAdjacentText('afterbegin', value); |
dom.append.text β |
element.insertAdjacentText('beforeend', value); |
dom.getClientRects β |
const rectCollection = element.getClientRects(); |
dom.getBoundingClientRect β |
const domRect = element.getBoundingClientRect(); |
dom.setAttribute β |
element.setAttribute('attrName', 'value'); |
dom.getAttribute β |
const attribute = element.getAttribute('attrName'); |
dom.hasAttribute β |
element.hasAttribute('attrName') |
dom.removeAttribute β |
element.removeAttribute('attrName'); |
dom.toggleAttribute β |
element.toggleAttribute('attrName'); |
dom.matches β |
element.matches('selectorString') |
dom.innerHTML β |
element.innerHTML = 'DOMString'; |
dom.outerHTML β |
element.outerHTML = 'DOMString'; |
dom.innerText β |
element.innerText = 'renderText'; |
dom.classList.add β |
element.classList.add('className'); |
dom.classList.contains β |
element.classList.contains('className'); |
dom.classList.remove β |
element.classList.remove('className'); |
dom.classList.replace β |
element.classList.replace('oldToken', 'newToken'); |
dom.classList.toggle β |
element.classList.toggle('className'); |
dom.scroll β |
element.scroll({top, left, behavior: 'smooth'}); |
dom.scrollBy β |
element.scrollBy({top, left, behavior: 'smooth'}); |
dom.scrollTo β |
element.scrollTo({top, left, behavior: 'smooth'}); |
dom.scrollIntoView β |
element.scrollIntoView({behavior: 'smooth'}); |
dom.clientWidth β |
element.clientWidth |
dom.clientHeight β |
element.clientHeight |
dom.clientLeft β |
element.clientLeft |
dom.clientTop β |
element.clientTop |
dom.scrollWidth β |
element.scrollWidth |
dom.scrollHeight β |
element.scrollHeight |
dom.scrollLeft β |
element.scrollLeft |
dom.scrollTop β |
element.scrollTop |
dom.offsetWidth β |
HTMLElement.offsetWidth |
dom.offsetHeight β |
HTMLElement.offsetHeight |
dom.offsetTop β |
HTMLElement.offsetTop |
dom.offsetLeft β |
HTMLElement.offsetLeft |
dom.offsetParent β |
HTMLElement.offsetParent |
| Prefix | Body | Description |
|---|---|---|
wa β |
window.alert('msg'); |
|
wc β |
window.confirm('msg'); |
|
wp β |
window.prompt('title', 'defaultText'); |
|
st β |
const timeout = window.setTimeout(() => { }, delay); window.clearTimeout(timeout); |
setTimeout |
stfn β |
var timeout = window.setTimeout(function() { }, delay); window.clearTimeout(timeout); |
|
si β |
const timer = window.setInterval(() => { }, interval); window.clearInterval(timer); |
setInterval |
sifn β |
var timer = window.setInterval(function() { }, interval); window.clearInterval(timer); |
|
lss β |
localStorage.setItem('key', 'value'); |
localStorage.setItem |
lsg β |
localStorage.getItem('key'); |
|
lsr β |
localStorage.removeItem('key'); |
|
lsc β |
localStorage.clear(); |
|
wsaw β |
window.screen.availWidth |
window.screen.availWidth |
wsah β |
window.screen.availHeight |
|
wsw β |
window.screen.width |
|
wsh β |
window.screen.height |
|
wlh β |
window.location.href |
|
wlhn β |
window.location.hostname |
|
wlp β |
window.location.pathname |
|
wlpr β |
window.location.protocol |
|
wls β |
window.location.assign(url) |
|
whb β |
window.history.back(); |
|
whf β |
window.history.forward(); |
|
wnl β |
window.navigator.language |
|
wnls β |
window.navigator.languages |
|
wnu β |
window.navigator.userAgent |
| Prefix | Body | Description |
|---|---|---|
cd β |
console.dir(); |
console.dir |
ce β |
console.error(); |
|
celb β |
console.error('foo: %o', foo); |
|
ci β |
console.info(); |
|
clg β |
console.log(); |
console.log |
clgl β |
console.log('foo: %o', foo); |
|
cw β |
console.warn(); |
|
cwl β |
console.warn('foo: %o', foo); |
|
ca β |
console.assert(expression, object); |
|
cc β |
console.clear(); |
|
cta β |
console.table(object); |
|
ct β |
console.time('label'); console.timeEnd('label'); |
|
ctr β |
console.trace(object); |
| Prefix | Body | Description |
|---|---|---|
ec β |
class name { constructor (param) { }} module.exports = name |
|
em β |
exports.member = value |
|
me β |
module.exports = name |
|
rq β |
require('module') |
|
crq β |
const module = require('module'); |
test.<method>
| Prefix | Body |
|---|---|
desc β |
describe('description', () => { }) |
cont β |
context('description', callback); |
it β |
it('description', () => { }) |
itas β |
it('description', async (done) => { done(); }); |
afe β |
afterEach(() => { }) |
bfe β |
beforeEach(() => { }) |
aft β |
after(() => { }) |
bf β |
before(() => { }) |
MIT License
Donate
