-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
181 lines (153 loc) · 7.05 KB
/
index.html
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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<link rel="stylesheet" href="./style.css">
<link rel="shortcut icon" href="./images/favicon.ico">
<title>Technical Documentation Page</title>
</head>
<body>
<nav id="navbar">
<header>JavaScript Documentation</header>
<a href="#Introduction" class="nav-link">Introduction</a>
<a href="#Hello_World" class="nav-link">Hello World</a>
<a href="#Variables" class="nav-link">Variables</a>
<a href="#Data_types" class="nav-link">Data types</a>
<a href="#if...else_statement" class="nav-link">if...else statement</a>
</nav>
<main id="main-doc">
<section class="main-section" id="Introduction">
<header>Introduction</header>
<p>JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight
language. Inside a host environment (for example, a web browser), JavaScript can be connected to the
objects of its environment to provide programmatic control over them.</p>
<p>JavaScript contains a standard library of objects, such as Array, Date, and Math, and a core set of
language elements such as operators, control structures, and statements. Core JavaScript can be
extended for a variety of purposes by supplementing it with additional objects; for example:
<ul id="introduction-list">
<li>Client-side JavaScript extends the core language by supplying objects to control a browser and
its Document Object Model (DOM). For example, client-side extensions allow an application to
place elements on an HTML form and respond to user events such as mouse clicks, form input, and
page navigation.</li>
<li>Server-side JavaScript extends the core language by supplying objects relevant to running
JavaScript on a server. For example, server-side extensions allow an application to communicate
with a database, provide continuity of information from one invocation to another of the
application, or perform file manipulations on a server.</li>
</ul>
</p>
</section>
<section class="main-section" id="Hello_World">
<header>Hello World</header>
<p>To get started with writing JavaScript, open the Scratchpad and write your first "Hello world"
JavaScript code:
<code>
function greetMe(yourName) {
alert("Hello " + yourName);
}
greetMe("World");
</code>
Select the code in the pad and hit Ctrl+R to watch it unfold in your browser!
</p>
</section>
<section class="main-section" id="Variables">
<header>Variables</header>
<p>You use variables as symbolic names for values in your application. The names of variables, called
identifiers, conform to certain rules.</p>
<p>A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent characters
can
also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z"
(uppercase) and the characters "a" through "z" (lowercase).</p>
<p>You can use ISO 8859-1 or Unicode letters such as å and ü in identifiers. You can also use the Unicode escape
sequences as characters in identifiers. Some examples of legal names are Number_hits, temp99, and _name.</p>
</section>
<section class="main-section" id="Data_types">
<header>Data types</header>
<p>
The latest ECMAScript standard defines seven data types:
<ul>
<li>Six data types that are primitives:
<ul>
<li>Boolean. true and false.</li>
<li>null. A special keyword denoting a null value. Because JavaScript is case-sensitive, null is not the
same as Null, NULL, or any other variant.</li>
<li>undefined. A top-level property whose value is undefined.</li>
<li>Number. 42 or 3.14159.</li>
<li>String. "Howdy"</li>
<li>Symbol (new in ECMAScript 2015). A data type whose instances are unique and immutable.</li>
</ul>
</li>
<li>and Object</li>
</ul>
</p>
<p>Although these data types are a relatively small amount, they enable you to perform useful functions with your
applications. Objects and functions are the other fundamental elements in the language. You can think of
objects as named containers for values, and functions as procedures that your application can perform.</p>
</section>
<section class="main-section" id="if...else_statement">
<header>if...else statement</header>
<p>
Use the if statement to execute a statement if a logical condition is true. Use the optional else clause to
execute a statement if the condition is false. An if statement looks as follows:
<code>
if (condition) {
statement_1;
} else {
statement_2;
}
</code>
condition can be any expression that evaluates to true or false. See Boolean for an explanation of what
evaluates to true and false. If condition evaluates to true, statement_1 is executed; otherwise, statement_2 is
executed. statement_1 and statement_2 can be any statement, including further nested if statements.
</p>
<p>
You may also compound the statements using else if to have multiple conditions tested in sequence, as follows:
<code>
if (condition_1) {
statement_1;
} else if (condition_2) {
statement_2;
} else if (condition_n) {
statement_n;
} else {
statement_last;
}
</code>
</p>
<p>
In the case of multiple conditions only the first logical condition which evaluates to true will be executed.
To execute multiple statements, group them within a block statement ({ ... }) . In general, it's good practice
to always use block statements, especially when nesting if statements:
<code>
if (condition) {
statement_1_runs_if_condition_is_true;
statement_2_runs_if_condition_is_true;
} else {
statement_3_runs_if_condition_is_false;
statement_4_runs_if_condition_is_false;
}
</code>
</p>
<p>
It is advisable to not use simple assignments in a conditional expression, because the assignment can be
confused with equality when glancing over the code. For example, do not use the following code:
<code>
if (x = y) {
/* statements here */
}
</code>
</p>
<p>
If you need to use an assignment in a conditional expression, a common practice is to put additional
parentheses around the assignment. For example:
<code>
if ((x = y)) {
/* statements here */
}
</code>
</p>
</section>
</main>
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
</body>
</html>