Updated Introduction to Editor Scripting.md (markdown)
commited
commit
47374eb08b0912c1d44bad6da35d1cd683871246
... | ... | @@ -21,17 +21,17 @@ Each of this key can represent either `num` value types (`int`, `float`), `tru` |
21 | 21 | ### Arrays and Objects |
22 | 22 | • An array basically acts as a list that is automatically indexed, you can declare an array like this |
23 | 23 | ``` |
24 | var list = ["apple", "orange", true, 100]; |
|
24 | var listA = ["apple", "orange", true, 100]; |
|
25 | 25 | |
26 | var list = []; |
|
27 | list[0] = "mango"; |
|
28 | list[2] = [0.1, 1]; |
|
26 | var listB = []; |
|
27 | listB[0] = "mango"; |
|
28 | listB[2] = [0.1, 1]; |
|
29 | 29 | //outputs ["mango",, [0.1, 1]] |
30 | 30 | ``` |
31 | 31 | |
32 | 32 | • In the other hand object is an "list of properties" to represent an "object", it works similarly to array but the properties are defined by a name as if it's a variable, you can declare an object like this: |
33 | 33 | ``` |
34 | var obj = { |
|
34 | var objA = { |
|
35 | 35 | name: "grass", |
36 | 36 | color: [0, 255, 0], |
37 | 37 | wilted: false, |
... | ... | @@ -41,7 +41,7 @@ var obj = { |
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | var obj = {}; |
|
45 | obj.something = "something"; |
|
44 | var objB = {}; |
|
45 | objB.something = "something"; |
|
46 | 46 | //outputs {something: "something"} |
47 | 47 | ``` |