Show Menu
Cheatography

Atom.io JavaScript snippets Cheat Sheet by

The default JavaScript snippets in the Atom.io editor

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

Func­tions

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:­tag­Nam­e}'})
qs
queryS­ele­cto­r($­{1:­'${­2:q­uer­y}'})
qsa
queryS­ele­cto­rAl­l($­{1:­'${­2:q­uer­y}'})
 

Cond­iti­onals

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}

Obje­cts

:
${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
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          AngularJS Cheat Sheet
          JavaScript Cheat Sheet

          More Cheat Sheets by StepK

          Vim NERDTree Cheat Sheet