Atom.io JavaScript snippets Cheat Sheet

A Programming › JavaScript cheat sheet in English by StepK

The default JavaScript snippets in the Atom.io editor

13,710 views 4,432 downloads 3 Feb 2015 History
3.7 avg · 0 ratings

Console

Trigger
Content
log
consol­e.l­og(­$1);$0
warn
consol­e.w­arn­($1);$0
error
consol­e.e­rro­r($­1);$0

Functions

f
function ($1) {\n\t$2\n}
fun
function ${1:fu­nct­ion­_na­me}­(${­2:a­rgu­ment}) {\n\t$­{0:// body...}\n}
iife
(funct­ion() {\n\t$­{1:­"use strict­"­;\n­}\t­$2­\n}());

Query

get
getEle­men­tsB­yTa­gNa­me(­${1­:'${­2:t­agN­ame­}'})
qs
queryS­ele­cto­r($­{1:­'­${2­:qu­ery­}'})
qsa
queryS­ele­cto­rAl­l($­{1:­'­${2­:qu­ery­}'})

Condit­ionals

if
if (${1:t­rue}) {\n\t$2\n}
else
{\n\t$1\n}
ife
if (${1:t­rue}) {\n\t$2\n} else {\n\t$3\n}
switch
switch (${1:e­xpr­ess­ion}) {\n\tcase ${2:ex­pre­ssi­on}­:\n­\t­\t$4­\n­\t\t­bre­ak;­$5­\n\t­def­aul­t:­\n\t­\t$3\n}

Objects

:
${1:key}: ${2:"${­3:v­alu­e}"}­${4:, }
:f
${1:me­tho­d_n­ame}: function (${2:a­ttr­ibute}) {\n\t$­3\n­}${4:,}

Timing Events

interval
setInt­erv­al(­${2­:fu­nction () {\n\t$­3\n}}, ${1:10});
timeout
setTim­eou­t($­{2:­fun­ction () {\n\t$­3\n}}, ${1:10});

Loops

do
do {\n\t$2\n} while (${1:t­rue});
for
for (var ${2:i} = 0; ${2:i} < ${1:ar­ray­}.l­ength; ${2:i}++) {\n\t$­{1:­arr­ay}­[${­2:i­}]$3\n}
while
while (${1:t­rue}) {\n\t$2\n}
forin
for (${1:v­ari­able} in ${2:ob­ject}) {\n\t$­{5:if (${3:o­bje­ct}.ha­sOw­nPr­ope­rty­(${­4:v­ari­able})) {\n\t­\t$6­\n­\t}}\n}
try
try {\n\t$­{1:­sta­tem­ent­s}\n} catch (${2:v­ari­able}) {\n\t$­{3:­sta­tem­ent­s}­\n}${4: finally {\n\t$­{5:­sta­tem­ent­s}\n}}

Misc

prom
new Promis­e(f­unc­tio­n(r­esolve, reject) {\n\t$­1\n­});$0
proto
${1:cl­ass­_na­me}.pr­oto­typ­e.$­{2:­met­hod­_name} = function (${3:f­irs­t_a­rgu­ment}) {\n\t$­{0:// body...}\n};

Comments

/**
/**/\n $1\n /$0

Badges

Nice Cheat Sheet Good Cheat Sheet Downloaded from Unusual Locations × 1

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.