-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs_coffee_cheat_sheet.tex
More file actions
124 lines (100 loc) · 3.32 KB
/
js_coffee_cheat_sheet.tex
File metadata and controls
124 lines (100 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{fullpage}
\usepackage{fancyhdr}
\usepackage{url}
\usepackage{color}
\usepackage{textcomp}
\usepackage{geometry}
\usepackage{courier}
\geometry{
top=1.0in, % <-- you want to adjust this
inner=0.5in,
outer=0.5in,
bottom=1.0in,
headheight=4ex, % <-- and this
headsep=3ex, % <-- and this
}
\renewcommand{\familydefault}{\sfdefault}
\addtolength{\parskip}{\baselineskip}
\pdfpagewidth 8.5in
\pdfpageheight 11in
\pagestyle{fancy}
\newcommand{\urlwofont}[1]{\urlstyle{same}\url{#1}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\lhead{\leftmark}
\chead{}
\rhead{\rightmark}
\lfoot{}
\cfoot{Page \thepage}
\rfoot{}
\hypersetup{
colorlinks=false,
linkcolor=blue,
citecolor=black,
filecolor=black,
urlcolor=blue
}
\begin{document}
\newpage
\section{JavaScript and CoffeeScript}
CoffeeScript is a language that compiles to JavaScript.
For more info, see \url{coffeescript.org}.
[TODO Useful CoffeeScript conveniences]
\section{jQuery}
jQuery is an awesome JavaScript library.
For more info, see \url{api.jquery.com} and \url{oscarotero.com/jquery}.
[TODO jQuery stuff]
\section{JSON}
JSON (JavaScript Object Notation) is an awesome text-based human-readable data interchange format. XML is another such format, but it's bloated and ugly.
In Angular Momentum, JSON is the format used when the frontend communicates with the backend, and when the backend responds.
For example, the frontend might issue a request to create a new message like:
\begin{verbatim}
{
"id": null,
"message": "Hello world!"
}
\end{verbatim}
And the backend might reply as:
\begin{verbatim}
{
"ok": true,
"message": {
"id": 123,
"message": "Hello world!",
"created_at": "2011-11-11 11:11:11"
}
}
\end{verbatim}
For more info, see \url{json.org}.
\subsection{The JSON format}
A \texttt{JSON value} is one of the following:
\begin{itemize}
\item{\texttt{null}}
\subitem{Represents nothingness.}
\item{\texttt{Boolean}}
\subitem{Represents a boolean value (\texttt{true} or \texttt{false}).}
\item{\texttt{Number}}
\subitem{Represents a number (integer or floating point format).}
\subitem{Examples: \texttt{11}; \texttt{-123.456}; \texttt{6.02e23}}
\item{\texttt{String}}
\subitem{Represents a string, delimited by double quotes (`` '').}
\subitem{Escape quotes (and other special characters) using backslash (\textbackslash).}
\subitem{Example: \texttt{"Hey\textbackslash nMy name is \textbackslash"John\textbackslash""}}
\item{\texttt{Array}}
\subitem{Represents an ordered collection of values.}
\subitem{Each element can be any \texttt{JSON value}.}
\subitem{The elements are comma-separated (trailing comma not allowed) and can be empty.}
\subitem{Example: \texttt{[true, 5, "John", [null, "Hey"], []]}}
\item{\texttt{Object}}
\subitem{Represents an ordered set of name/value pairs.}
\subitem{Each key must be a \texttt{String}. Each value can be any \texttt{JSON value}.}
\subitem{Keys must be distinct.}
\subitem{The key/value pairs are comma-separated (trailing comma not allowed) and can be empty.}
\subitem{Example: \texttt{\{"a": 1, "b": "c", "hey": [1, 2, 3, \{\}]\}}}
\end{itemize}
\end{document}