Login

Fancade Wiki

Updated Introduction to Editor Scripting.md (markdown)

... ...
@@ -17,13 +17,29 @@ Unlike most programming languages JS uses a versatile variable declaration this
17 17
Each of this key can represent either `num` value types (`int`, `float`), `tru` types (`bool`), or `String` and can be changed to anytime according to the value type it holds. Additionally it can also declare arrays, objects and functions.
18 18
19 19
### Arrays and Objects
20
An array basically acts as a list that is automatically indexed, you can declare an array like this
20
An array basically acts as a list that is automatically indexed, you can declare an array like this
21 21
```
22
var sample = ["apple", "orange", true, 100];
22
var list = ["apple", "orange", true, 100];
23 23
24
var sample = [];
25
sample[0] = "mango";
26
sample[2] = 0.1;
27
//outputs ["mango",, 0.1]
24
var list = [];
25
list[0] = "mango";
26
list[2] = [0.1, 1];
27
//outputs ["mango",, [0.1, 1]]
28 28
```
29 29
30
• In the other hand object is an "list of properties" to represent an "object", it works similarly with array but the properties are defined by a name as if it's a variable, you can declare an object like this:
31
```
32
var obj = {
33
name: "grass",
34
color: [0, 255, 0],
35
wilted: false,
36
leaf: {
37
type: "pointy",
38
count: 4
39
}
40
}
41
42
var obj = {};
43
obj.something = "something";
44
//outputs {something: "something"}
45
```
Fancade Wiki