oncework / snippets-javascript

A snippet pack to make you more productive working with JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript Snippet Pack for CodeExpander

A snippet pack to make you more productive working with JavaScript.

This extension ships a bunch of useful code snippets for the JavaScript and TypeScript editors.

Here's the full list of all the snippets:

Console

[cd] console.dir

console.dir(%c%);

[ce] console.error

console.error(%c%);

[ci] console.info

console.info(%c%);

[cl] console.log

console.log(%c%);

[cw] console.warn

console.warn(%c%);

[de] debugger

debugger;

DOM

[ae] addEventListener

%c%document.addEventListener('%c%load', function(e) {
	%c%
});

[ac] appendChild

%c%document.appendChild(%c%elem);

[rc] removeChild

%c%document.removeChild(%c%elem);

[cel] createElement

%c%document.createElement(%c%elem);

[cdf] createDocumentFragment

%c%document.createDocumentFragment();

[ca] classList.add

%c%document.classList.add('%c%class');

[ct] classList.toggle

%c%document.classList.toggle('%c%class');

[cr] classList.remove

%c%document.classList.remove('%c%class');

[gi] getElementById

%c%document.getElementById('%c%id');

[gc] getElementsByClassName

%c%document.getElementsByClassName('%c%class');

[gt] getElementsByTagName

%c%document.getElementsByTagName('%c%tag');

[ga] getAttribute

%c%document.getAttribute('%c%attr');

[sa] setAttribute

%c%document.setAttribute('%c%attr',  %c%);

[ra] removeAttribute

%c%document.removeAttribute('%c%attr');

[ih] innerHTML

%c%document.innerHTML = '%c%elem';

[tc] textContent

%c%document.textContent = '%c%content';

[qs] querySelector

%c%document.querySelector('%c%selector');

[qsa] querySelectorAll

%c%document.querySelectorAll('%c%selector');

Loop

[fe] forEach

%c%array.forEach(function(item) {
	%c%
});

Function

[fn] function

function %c%methodName (%c%arguments) {
	%c%// body
}

[afn] anonymous function

function(%c%arguments) {
	%c%// body
}

[pr] prototype

%c%object.prototype.%c%method = function(%c%arguments) {
	%c%// body
}

[iife] immediately-invoked function expression

(function(%c%window, %c%document) {
	%c%// body
})(%c%window, %c%document);

[call] function call

%c%.call(%c%context, %c%arguments)

[apply] function apply

%c%.apply(%c%context, [%c%arguments])

[ofn] function as a property of an object

%c%: function(%c%arguments) {
	%c%// body
}

JSON

[jp] JSON.parse

JSON.parse(%c%);

[js] JSON.stringify

JSON.stringify(%c%);

Timer

[si] setInterval

setInterval(function() {
	%c%// body
}, %c%1000);

[st] setTimeout

setTimeout(function() {
	%c%
}, %c%1000);

Misc

[us] use strict

'use strict';

[al] alert

alert('%c%msg');

[co] confirm

confirm('%c%msg');

[pm] prompt

prompt('%c%msg');

License

MIT License

About

A snippet pack to make you more productive working with JavaScript

License:MIT License