JS Snippets
JavaScript snippets for Sublime Text 2.
Details
Installs
- Total 104K
- Win 73K
- Mac 17K
- Linux 14K
Mar 29 | Mar 28 | Mar 27 | Mar 26 | Mar 25 | Mar 24 | Mar 23 | Mar 22 | Mar 21 | Mar 20 | Mar 19 | Mar 18 | Mar 17 | Mar 16 | Mar 15 | Mar 14 | Mar 13 | Mar 12 | Mar 11 | Mar 10 | Mar 9 | Mar 8 | Mar 7 | Mar 6 | Mar 5 | Mar 4 | Mar 3 | Mar 2 | Mar 1 | Feb 28 | Feb 27 | Feb 26 | Feb 25 | Feb 24 | Feb 23 | Feb 22 | Feb 21 | Feb 20 | Feb 19 | Feb 18 | Feb 17 | Feb 16 | Feb 15 | Feb 14 | Feb 13 | Feb 12 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 5 | 1 | 3 | 4 | 2 | 0 | 2 | 0 | 2 | 1 | 0 | 5 | 1 | 1 | 3 | 1 | 3 | 3 | 1 | 0 | 1 | 1 | 2 | 2 | 1 | 3 | 3 | 1 | 1 | 0 | 2 | 2 | 5 | 7 | 1 | 3 | 0 | 2 | 1 | 1 | 1 | 1 | 1 | 4 |
Mac | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |
Readme
- Source
- raw.githubusercontent.com
Sublime Text 2 JS Snippets
In order to use the snippets, just enter the shortcode and press the Tab (or whatever you have set as completion key) to use the snippets.
Included are all snippets listed below. $1, $2, etc. show the position where the caret will appear whenever you press the tab key inside the snippet.
These snippets are intended to be used by regular people trying to make their JavaScript development a little easier. If you want more complex snippets, use JP Richardson's JavaScript snippets.
You're free to alter the snippets in any way imaginable. Add new ones, remove old ones, do whatever you like. If you've found something interesting, go ahead and make a pull request or send me a tweet.
cls
localStorage.clear();
do
do {
${1:expression}
} while (${2:condition});
eve
${1:element}.addEventListener('$2', function (e) {
$3
}, false);
if
if (${1:condition}) {
${2:expression}
}
ife
if (${1:condition}) {
${2:expression}
} else {
${3:other expression}
}
interval
setInterval(${1:function}, ${2:delay});
for
for (${1:var i = 0}; ${2:i < ${3:elements.length}}; ${4:i++}) {
${5:expression}
}
fori
for (${1:prop} in ${2:object}) {
if (${2:object}.hasOwnProperty(${1:prop})) {
${3:expression}
}
}
log
console.log(${1:'test'});
ls
if (localStorage.${1:item}) {
var ${1:item} = localStorage.${1:item};
$2
}
pd
e.preventDefault();
rand
Math.floor(Math.random() * ${1:10})
switch
switch(${1:var}) {
case $2:
$3
break;
case $4:
$5
break;
}
timeout
setTimeout(${1:function}, ${2:delay});
while
while (${1:condition}) {
${2:expression}
};