-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02-javascript-syntax.html
More file actions
182 lines (141 loc) · 6.45 KB
/
02-javascript-syntax.html
File metadata and controls
182 lines (141 loc) · 6.45 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="pt-br">
<head>
<link rel="stylesheet" href="css/default.css">
<script src="tools/indice.js"></script>
<script>var current_class="sintaxe";</script>
<script src="highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Sintaxe</title>
<link href="https://fonts.googleapis.com/css?family=Poppins:400,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<div class="page-container">
<header>
<div class="logo-area">
<img src="img/logo_js.png" alt="logo javascript">
</div>
<div class="course-title">
<h1>Javascript Course for Beginners</h1>
<h2>Instructor: Ivan Lourenço Gomes</h2>
</div>
</header>
<main>
<h3>Javascript Syntax</h3>
<h4>Statements</h4>
<p>
Statements are instructions to be executed by the web browser. Every statement should
be finished with a semicolon ( ; ). The Javascript code is composed of multiple statements
that will be executed in sequential order, from top to bottom.
</p>
<pre>
<code class="javascript">
console.log('statement 1');
console.log('statement 2');
</code>
</pre>
<p>
</p>
<p>
Each web browser has its own Javascript interpreter that is responsible for executing the statements we write.
They are also called Javascript engines. See the table below for the interpreters of the most popular web browsers:
</p>
<div class="tableBox">
<table>
<tr>
<th>Browser</th>
<th>Interpreter</th>
</tr>
<tr>
<td>Google Chrome</td>
<td><a target="_blank" href="https://developers.google.com/v8/?hl=pt">V8</a> </td>
</tr>
<tr>
<td>Mozilla Firefox</td>
<td>
<a target="_blank" href="https://developer.mozilla.org/pt-PT/docs/Gecko">Gecko</a>,
<a target="_blank" href="https://developer.mozilla.org/pt-PT/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> e
<a target="_blank" href="https://developer.mozilla.org/pt-PT/docs/Mozilla/Projects/Rhino">Rhino</a>.
</td>
</tr>
<tr>
<td>Safari</td>
<td>Nitro</td>
</tr>
<tr>
<td>Microsoft Edge</td>
<td>Chakra</td>
</tr>
<tr>
<td>Opera</td>
<td><a target="_blank" href="https://dev.opera.com/blog/carakan/">Carakan</a> </td>
</tr>
</table>
</div>
<h4>Comments</h4>
<p>
Like every other programming language, we can use comments in Javascript to indicate lines of code that should be ignored
by the interpreter.
The double forward slashes ( // ) are used for one-line comments and multi-line comments can be done just like in
CSS, starting with ( /* ) and ending with ( */ ).
</p>
<pre>
<code class="javascript">
// This line of code is commented and will be ignored by the web browser
console.log('This statement will be executed');
// console.log('This statement has been commented and will be ignored');
/*
None of these lines
will be executed
by the interpreter
console.log('This statement will be ignored');
*/
</code>
</pre>
<p>
The most popular text editors have shortcuts to toggle comments. In Visual Studio Code you can use SHIFT + ALT + A to
comment or uncomment lines of code. You can also find those option in the menu Edit > Toggle Line Comment and
Toggle Block Comment.
</p>
<h4>Case Sensitive</h4>
<p>
Javascript is a case sensitive language, which means that:
</p>
<pre>
<code class="javascript">
// This:
console.log('something');
// Is not the same as this:
Console.log('something');
</code>
</pre>
<p>
The last example will result in an error because there's no object called "Console"
with a capital "C". Because of this, we should be very careful with the names of
objects, properties and methods so we don't make mistakes that will generate errors
in our code.
</p>
<div id="bottom-area">
<div class="prev-next-link">
<div class="link-aula" id="prev_class">
</div>
<div class="link-aula" id="next_class">
</div>
</div>
<div class="classes">
<h3>
Contents
</h3>
<ul id="class_index">
</ul>
</div>
</div>
</main>
</div>
<script src="js/scripts.js"></script>
</body>
</html>