A collection of common javascript statement snippets for faster development in Visual Studio Code.
Feel free to install the extension from VS Code or from here.
See the demo.
let ${1:name} = ${2:value}
var ${1:name} = ${2:value}
const ${1:name} = ${2:value}
let ${1:name} = [${2:value1}, ${3:value2}]
let ${1:name} = {
"${2:key}": ${3:value}
}
const ${1:name} = (${2:param}) => {
}
function ${1:name} (${2:param}) {
}
${1:value1} === ${2:value2}
${1:value1} !== ${2:value2}
${1:value1} > ${2:value2}
${1:value1} < ${2:value2}
${1:value1} >= ${2:value2}
${1:value1} <= ${2:value2}
${1:condition1} || ${2:condition2}
${1:condition1} && ${2:condition2}
let ${1:name} = ${2:condition} ? ${3:value1} : ${4:value2}
${1:value}.length === 0
${1:value}.length > 0
${1:value} === ""
${1:value} !== ""
${1:value} === null
${1:value} !== null
typeof ${1:value} === "undefined"
typeof ${1:value} !== "undefined"
${1:value1} instanceof ${2:value2}
Array.isArray(${1:value}) || ${1:value}.length
Object.keys(${1:value}).length === 0 && ${1:value}.constructor === Object
${1:value1}.indexOf(${2:value2}) > -1
${1:value1}.indexOf(${2:value2}) === -1
document.addEventListener("${1:event}", (${2:param}) => {
})
document.removeEventListener("${1:event}", (${2:param}) => {
})
document.createElement("${1:value}")
document.appendChild("${1:value}")
document.removeChild("${1:value}")
document.getElementById("${1:value}")
document.getElementsByClassName("${1:value}")
document.getElementsByTagName("${1:value}")
document.querySelector("${1:value}")
document.querySelectorAll("${1:value}")
console.log(${1:value})
console.warn(${1:value})
console.error(${1:value})
let { ${1:value1} } = ${2:value2}
let [${1:value1}, ${2:value2}] = ${3:value3}
this.${1:name} = this.${1:name}.bind(this)
let ${1:name} = ...${2:value}
`${${1:value}}`
`${${1:value1}} ${${2:value2}}`
`${${1:value1}} ${${2:value2}} ${${3:value3}}`
// Assignments
let name = value // la
var name = value // va
const name = value // ca
let name = { // oa
"key": value
}
let name = [value1, value2] // aa
// Functions
const name = (param) => { // af
}
function name (param) { // nf
}
// Conditions
value1 === value2 // ec
value1 !== value2 // nec
value1 > value2 // gtc
value1 < value2 // ltc
value1 >= value2 // getc
value1 <= value2 // letc
condition1 || condition2 // oc
condition1 && condition2 // ac
let name = condition ? value1 : value2 // co
// Validations
value.length === 0 // zlv
value.length > 0 // plv
value === "" // esv
value !== "" // nesv
value === null // nv
value !== null // nnv
typeof value === "undefined" // uv
typeof value !== "undefined" // nuv
value1 instanceof value2 // iov
Array.isArray(value) || value.length // av
Object.keys(value).length === 0 && value.constructor === Object // ov
value1.indexOf(value2) > -1 // cv
value1.indexOf(value2) === -1 // dcv
// DOM manipulations
document.addEventListener("event", (param) => { // ael
})
document.removeEventListener("event", (param) => { // rel
})
document.createElement("value") // cel
document.appendChild("value") // ach
document.removeChild("value") // rch
document.getElementById("value") // gei
document.getElementsByClassName("value") // gec
document.getElementsByTagName("value") // get
document.querySelector("value") // qs
document.querySelectorAll("value") // qsa
// Console
console.log(value) // cl
console.warn(value) // cw
console.error(value) // ce
// Destructuring
let { value1 } = value2 // od
let [value1, value2] = value3 // ad
// Others
// Specially for ReactJS developers
this.name = this.name.bind(this) // rbt
let name = ...value // car
`${value}` // ph1
`${value1} ${value2}` // ph2
`${value1} ${value2} ${value3}` // ph3
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
Code by Dimitar Dyakov. Copyright 2019