Skip to content
| Marketplace
Sign in
Visual Studio>Tools>JavaScript Snippet Pack
JavaScript Snippet Pack

JavaScript Snippet Pack

Mads Kristensen

|
486,001 installs
| (12) | Free
A snippet pack to make you more productive working with JavaScript.
Download

A snippet pack to make you more productive working with JavaScript. Based on theAtom snippets.

Snippet manager

This extension ships a bunch of useful code snippets for the JavaScript editor. Get an overview from theCode Snippet Manager in Visual Studio located under the Tools top level menu.

Snippet manager

Here's the full list of all the snippets:

Console

[cd] console.dir

console.dir(${1:obj});

[ce] console.error

console.error($end$);

[ci] console.info

console.info($end$);

[cl] console.log

console.log($end$);

[cw] console.warn

console.warn($end$);

[de] debugger

debugger;

DOM

[ae] addEventListener

$document$.addEventListener('$event$', function(e) {    $end$});

[ac] appendChild

$document$.appendChild($elem$);

[rc] removeChild

$document$.removeChild($elem$);

[cel] createElement

$document$.createElement($elem$);

[cdf] createDocumentFragment

$document$.createDocumentFragment($elem$);

[ca] classList.add

$document$.classList.add('$class$');

[ct] classList.toggle

$document$.classList.toggle('$class$');

[cr] classList.remove

$document$.classList.remove('$class$');

[gi] getElementById

$document$.getElementById('$id$');

[gc] getElementsByClassName

$document$.getElementsByClassName('$class$');

[gt] getElementsByTagName

$document$.getElementsByTagName('$tag$');

[ga] getAttribute

$document$.getAttribute('$attr$');

[sa] setAttribute

$document$.setAttribute('$attr$', $value$);

[ra] removeAttribute

$document$.removeAttribute('$attr$');

[ih] innerHTML

$document$.innerHTML = '$elem$';

[tc] textContent

$document$.textContent = '$content$';

[qs] querySelector

$document$.querySelector('$selector$');

[qsa] querySelectorAll

$document$.querySelectorAll('$selector$');

Loop

[fe] forEach

$myArray$.forEach(function($item$) {    $end$});

Function

[afn] anonymous function

function($arguments$) {    $end$}

[pr] prototype

$object$.prototype.$methodName$ = function($arguments$) {    $end$}

[call] function call

$methodName$.call($context$, $arguments$)

[apply] function apply

$methodName$.apply($context$, [$arguments$])

[ofn] function as a property of an object

$functionName$: function($arguments$) {    $end$}

JSON

[jp] JSON.parse

JSON.parse($object$);

[js] JSON.stringify

JSON.stringify($object$);

Timer

[si] setInterval

setInterval(function() {    $end$}, $delay$);

[st] setTimeout

setTimeout(function() {    $end$}, $delay$);

Misc

[us] use strict

'use strict';

[al] alert

alert('$message$');

[co] confirm

confirm('$message$');

[pm] prompt

prompt('$message$');

 

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