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

SnipJS

Dimitar Dyakov

|
279 installs
| (3) | Free
Common javascript statement snippets.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

SnipJS

A collection of common javascript statement snippets for faster development in Visual Studio Code.


  • Assignments
  • Functions
  • Conditions
  • Validations
  • DOM manipulations
  • Others

Assignments

la => let assignment

let ${1:name} = ${2:value}

va => var assignment

var ${1:name} = ${2:value}

ca => const assignment

const ${1:name} = ${2:value}

aa => array assignment

let ${1:name} = [${2:value1}, ${3:value2}]

oa => object assignment

 let ${1:obj} = {
     "${2:key}": ${3:value}
 }

Functions

af => arrow function

const ${1:name} = (${2:param}) => {

}

nf => named function

function ${1:name} (${2:param}) {

}

Conditions

ac => and condition

${1:condition1} && ${2:condition2}

oc => or condition

${1:condition1} || ${2:condition2}

co => condition operator

let ${1:name} = ${2:condition} ? ${3:value1} : ${4:value2}

Validations

lv => length validation

${1:value}.length === ${2:0}

nv => null validation

${1:value} === null

nnv => not null validation

${1:value} !== null

uv => undefined validation

typeof ${1:value} === "undefined"

nuv => not undefined validation

typeof ${1:value} !== "undefined"

cv => contains validation

${1:value}.indexOf(${2:value2}) > -1

dcv => doesn't contain validation

${1:value}.indexOf(${2:value2}) === -1

DOM manipulations

ael => add event listener

document.addEventListener("${1:event}", (${2:param}) => {

})

rel => remove event listener

document.removeEventListener("${1:event}", (${2:param}) => {

})

ce => create element

document.createElement("${1:element}")

gei => get element by id

document.getElementById("${1:id}")

gec => get element by class name

document.getElementsByClassName("${1:class}")

qs => query selector

document.querySelector("${1:selector}")

qsa => query selector all

document.querySelectorAll("${1:selector}")

Others

od => object destructuring

const { ${1:name} } = ${2:value}

cl => console log

console.log(${1:value})

Questions, problems or something else?

There is a bug? Leave an issue on the issues page or send a pull request with new features.
For questions, do not hesitate to write me an email - dimitar.dyakov98@gmail.com
Leave a star if you like and find the snippets helpful!

Code by Dimitar Dyakov. Copyright 2019

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft