Skip to content

Commit 61924da

Browse files
committed
First step in order to redo the generated site
1 parent c69ecba commit 61924da

35 files changed

+2038
-485
lines changed
File renamed without changes.

doc/arrays.md renamed to doc/array/general.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
## Arrays
1+
## Array iteration and properties
22

33
Although arrays in JavaScript are objects, there are no good reasons to use
4-
the [for in loop](#forinloop) in for iteration on them. In fact there are a
5-
number of good reasons **against** the use of `for in` on arrays.
4+
the [for in loop](#object.forinloop) in for iteration on them. In fact there are
5+
a number of good reasons **against** the use of `for in` on arrays.
66

77
> **Note:** JavaScript arrays are **not** *associative arrays*. JavaScript only
8-
> has [objects](#objects) for mapping keys to values. And while associative
8+
> has [objects](#object.general) for mapping keys to values. And while associative
99
> arrays **preserve** order, objects do **not**.
1010
1111
Since the `for in` loop enumerates all properties on the prototype chain and
1212
the only way to exclude those properties is to use
13-
[`hasOwnProperty`](#hasownproperty), it is already up to **twenty times** slower
14-
than a normal `for` loop.
13+
[`hasOwnProperty`](#object.hasownproperty), it is already up to **twenty times**
14+
slower than a normal `for` loop.
1515

1616
### Iteration
1717

doc/eval.md renamed to doc/core/eval.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ achieved **without** it.
2929

3030
### `eval` in disguise
3131

32-
The [timeout functions](#timeouts) `setTimeout` and `setInterval` can both take a string as
33-
their first argument. This string will **always** get executed in the global
34-
scope since `eval` is not being called directly in that case.
32+
The [timeout functions](#other.timeouts) `setTimeout` and `setInterval` can both
33+
take a string as their first argument. This string will **always** get executed
34+
in the global scope since `eval` is not being called directly in that case.
3535

3636
### Security issues
3737

File renamed without changes.

doc/undefined.md renamed to doc/core/undefined.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ necessary to retrieve the value of `undefined` in the first place.
3131

3232
In order to protect code against a possible overwritten `undefined` variable, a
3333
common technique used is to add an additional parameter to the encapsulation
34-
[anonymous wrapper](#scopes), which gets no argument passed to it.
34+
[anonymous wrapper](#function.scopes), which gets no argument passed to it.
3535

3636
var undefined = 123;
3737
(function(something, foo, undefined) {
File renamed without changes.

doc/closures.md renamed to doc/function/closures.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
One of JavaScript's most powerful features is the availability of *closures*,
44
this means that scopes **always** keep access to the outer scope they were
55
defined in. Since the only scope that JavaScript has is the
6-
[function scope](#scopes), all functions, by default, act as closures.
6+
[function scope](#function.scopes), all functions, by default, act as closures.
77

88
### Emulating private variables
99

@@ -67,7 +67,7 @@ the value of `i`.
6767
### Avoiding the reference problem
6868

6969
In order to copy the value of the loop its index variable, it is best to use an
70-
[anonymous wrapper](#scopes).
70+
[anonymous wrapper](#function.scopes).
7171

7272
for(var i = 0; i < 10; i++) {
7373
(function(e) {

doc/constructors.md renamed to doc/function/constructors.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Constructors in JavaScript are yet again different from many other languages. An
44
function call that is preceded by the `new` keyword acts as a constructor.
55

66
Inside the constructor (the called function) the value of `this` refers to a
7-
newly created `Object`. The [`prototype`](#prototype) of this **new** object is
8-
set to the `prototype` of the function object that was called.
7+
newly created `Object`. The [`prototype`](#object.prototype) of this **new**
8+
object is set to the `prototype` of the function object that was called.
99

1010
If the function that was called has no explicit `return` statement, then it
1111
implicitly returns the value of `this` (the new object). Otherwise it returns
@@ -27,8 +27,8 @@ created object to `Foo.prototype`.
2727

2828
Keep in mind that if you do not use the `new` keyword the function will **not**
2929
return a new object. While it might still work due to the workings of
30-
[`this`](#how-this-works-in-javascript) in JavaScript, it will use the *global*
31-
object as the value of `this`.
30+
[`this`](#function.this) in JavaScript, it will use the *global* object as the
31+
value of `this`.
3232

3333
### Factories
3434

@@ -51,7 +51,7 @@ explicitly return a value.
5151
Bar();
5252

5353
Both these calls return the exact same thing, a newly create object which
54-
has a property called `method` which is a [Closure](#closures-and-references).
54+
has a property called `method` which is a [Closure](#function.closures).
5555

5656
Also note that the call `new Bar()` does **not** affect the prototype of the
5757
returned object. While the prototype will be set on the newly created object,
@@ -85,7 +85,7 @@ object inside it.
8585
}
8686

8787
While the above is robust against forgetting to use `new` and makes the use of
88-
[private variables](#closures) certainly easier, it comes with some down sides.
88+
[private variables](#function.closures) certainly easier, it comes with some down sides.
8989

9090
1. It uses more memory since the created objects do **not** share the methods
9191
2. In order to inherit the factory needs to copy all the methods from another

doc/functions.md renamed to doc/function/general.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Functions
1+
## Function declarations and expressions
22

33
Functions in JavaScript are first class objects, which means that they can be
44
passed around like any other value. One common use of this feature is to pass
@@ -30,7 +30,7 @@ declaration - creates the variable `foo` before the actual execution of the code
3030
starts, `foo` is already defined when the script gets executed.
3131

3232
Since assignments only happens at runtime, the value of `Foo` will default
33-
to [undefined](#undefined) before the corresponding code is executed.
33+
to [undefined](#core.undefined) before the corresponding code is executed.
3434

3535
### Named function expression
3636

@@ -43,7 +43,7 @@ Another special case is the assignment of named functions.
4343

4444
Here `bar` is not available in the outer scope, since the function only gets
4545
assigned to `foo`; however, inside of `bar` it **is** available. This is due to
46-
how [name resolution](#scopes) in JavaScript works, the name of the function
46+
how [name resolution](#function.scopes) in JavaScript works, the name of the function
4747
is always made available in the local scope of the function itself.
4848

4949
### The `var` statement
@@ -62,8 +62,8 @@ is always made available in the local scope of the function itself.
6262
var foo = 1;
6363
}
6464

65-
Since there is **no** [block scope](#scopes) in JavaScript, the above will
66-
**not** assign the value `2` to the *global* variable `bar`. It will rather
65+
Since there is **no** [block scope](#function.scopes) in JavaScript, the above
66+
will **not** assign the value `2` to the *global* variable `bar`. It will rather
6767
assign the value of `2` to the *local* variable `bar` of `test`.
6868

6969
Also, while the statements inside the `if` block never get executed, the variable

doc/scopes.md renamed to doc/function/scopes.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ is in the language is *function scope*.
1414
> **Note:** When not used in an assignment, return statement or as a function
1515
> argument, the `{...}` notation will get interpreted as a block statement and
1616
> **not** as an object literal. This, in conjunction with
17-
> [automatic insertion of semicolons](#semicolon), can lead to subtle errors.
17+
> [automatic insertion of semicolons](#core.semicolon), can lead to subtle errors.
1818
1919
There are also no distinct namespaces in JavaScript. This means that everything
2020
gets defined in **one** globally shared namespace.
@@ -72,8 +72,9 @@ unless the desired effect **is** to affect the outer scope.
7272

7373
### Local variables
7474

75-
The only source for local variables in JavaScript are [function](#functions)
76-
parameters and variables that were declared via the `var` statement.
75+
The only source for local variables in JavaScript are
76+
[function](#function.general) parameters and variables that were declared via the
77+
`var` statement.
7778

7879
// global scope
7980
var foo = 1;
@@ -95,9 +96,9 @@ the assignment of `bar` will override the global variable with the same name.
9596
### Name resolution order
9697

9798
All scopes in JavaScript - including the global one - have the name
98-
[this](#this) defined in them, which refers to the "current object".
99+
[this](#function.this) defined in them, which refers to the "current object".
99100

100-
Function scopes also have the name [arguments](#arguments) defined, which
101+
Function scopes also have the name [arguments](#function.arguments) defined, which
101102
contains the arguments that were passed to a function.
102103

103104
For example, when trying to access a variable named `foo` inside the scope of a
@@ -127,8 +128,8 @@ easily avoided with the help of anonymous *function wrappers*.
127128
})(); // execute the function immediately
128129

129130

130-
Unnamed functions are considered [expressions](#functions); so in order to being
131-
callable, they must first be evaluated.
131+
Unnamed functions are considered [expressions](#function.general); so in order to
132+
being callable, they must first be evaluated.
132133

133134
( // evaluate the function inside the paranthesis
134135
function() {}

0 commit comments

Comments
 (0)