- Notifications
You must be signed in to change notification settings - Fork8
✂️ Visual Studio Code snippets for JavaScript, TypeScript, and React
License
nathanchapman/vscode-javascript-snippets
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Visual Studio Code snippets for JavaScript, TypeScript, and React
Code snippets are templates that make it easier to autocomplete repeating code patterns. They're like shortcuts for writing code.
Just install this package from theExtension Marketplace, then add"editor.snippetSuggestions": "top"
to youruser settings to see these snippets on top in the suggestion popover. Make sure you've also set"editor.tabCompletion": "on"
fortab
completion.
These snippets are optimized to be short and easy to remember.They followJavaScript Standard Style.They also supporttab
autocompletion to accelerate your workflow!
Below is a list of all available snippets and the shortcuts for each one. The⇥
means thetab
key.
var${0}
var${1:name}=${2:value}
let${0}
let${1:name}=${2:value}
let{${1:name}}= ${2:value}
const${0}
const${1:name}=${2:value}
const{${1:name}}= ${2:value}
if(${1:condition}){${0}}
else{ ${0}}
if(${1:condition}){${0}}else{}
elseif(${1:condition}){ ${0}}
${1:condition} ?${2:expression} :${3:expression}
for(let${1:i}=0,${2:len}=${3:iterable}.length;${1:i}<${2:len};${1:i}++){${0}}
for(let${1:i}=${2:iterable}.length-1;${1:i}>=0;${1:i}--){${0}}
for(let${1:key}in${2:array}){if(${2:array}.hasOwnProperty(${1:key})){${0}}}
},
for(let${1:key}of${2:array}){${0}}
while(${1:condition}){${0}}
try{${0}}catch(${1:err}){}
try{${0}}finally{}
try{${0}}catch(${1:err}){}finally{}
switch(${1:expr}){case${2:value}:return$0default:return}
function(${1:arguments}){${0}}
function${1:name}(${2:arguments}){${0}}
((${1:arguments})=>{${0}})(${2})
${1:fn}.apply(${2:this},${3:arguments})
${1:fn}.call(${2:this},${3:arguments})
${1:fn}.bind(${2:this},${3:arguments})
(${1:arguments})=>${2:statement}
(${1:arguments})=>{${0}}
function*(${1:arguments}){${0}}
function*${1:name}(${2:arguments}){${0}}
[...Array(${1:length}).keys()]${0}
${1}.forEach((${2:item})=>{${0}})
${1}.map((${2:item})=>{${0}})
${1}.reduce((${2:previous},${3:current})=>{ ${0}}${4:,initial})
${1}.filter(${2:item}=>{${0}})
${1}.find(${2:item}=>{${0}})
{kv${0}}
{kv${0}}
${1:key}: ${2:value},
class${1:name}{constructor(${2:arguments}){${0}}}
class${1:name}extends${2:base}{constructor(${3:arguments}){super(${3:arguments})${0}}}
constructor(${1:arguments}){super(${1:arguments})${0}}
${1:method}(${2:arguments}){${0}}
get${1:property}(){${0}}
set${1:property}(${2:value}){${0}}
get${1:property}(){${0}}set${1:property}(${2:value}){}
var${1:Class}=function(${2:arguments}){${0}}
${1:Class}.prototype.${2:method}=function(${3:arguments}){${0}}
Object.assign(${1:dest},${2:source})
Object.assign({},${1:original},${2:source})
return${0}
returnnewPromise((resolve,reject)=>{${0}})
return(${0})
typeof${1:source}==='${2:undefined}'
${1:source}instanceof${2:Object}
newPromise((resolve,reject)=>{${0}})
${1:promise}.then((${2:value})=>{${0}})
${1:promise}.catch((${2:err})=>{${0}})
export${1:member}
exportdefault${1:member}
import${1:*}from'${2:module}'
import${1:*}as ${2:name}from'${3:module}'
(err,${1:value})=>{${0}}
require('${1:module}')
require('./${1:module}')
const${1:module}=require('${1:module}')
const${1:module}=require('./${1:module}')
const{${1:module}}=require('${1:module}')
const{${1:module}}=require('./${1:module}')
exports.${1:member}=${2:value}
module.exports=${1:name}
module.exports={${1:member}}
${1:emitter}.on('${2:event}',(${3:arguments})=>{${0}})
describe('${1:description}',()=>{${0}})
context('${1:description}',()=>{${0}})
it('${1:description}',()=>{${0}})
it('${1:description}',async()=>{${0}})
it('${1:description}',(done)=>{${0}done()})
before(()=>{${0}})
beforeEach(()=>{${0}})
after(()=>{${0}})
afterEach(()=>{${0}})
console.log(${0})
console.error(${0})
console.warn(${0})
console.log('${0}',${0})
console.error('${0}',${0})
console.warn('${0}',${0})
setTimeout(()=>{${0}},${1:delay})
setInterval(()=>{${0}},${1:delay})
setImmediate(()=>{${0}})
process.nextTick(()=>{${0}})
'use strict'
staticpropTypes={$0}
staticdefaultProps={$0}
staticgetDerivedStateFromProps(${1:nextProps},${2:prevState}){$0}
static defaultProps:Partial<${1:${TM_FILENAME_BASE}Props}>={$0}
staticgetDerivedStateFromProps(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}},${4:prevState}: ${6:${TM_FILENAME_BASE}${5:State}}):Partial<${6:${TM_FILENAME_BASE}${5:State}}>{$0}
About
✂️ Visual Studio Code snippets for JavaScript, TypeScript, and React
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.