@@ -11,15 +11,15 @@ Since Java and JavaScript are quite similar programming languages you do not hav
11
11
12
12
### Comments
13
13
14
- ```
14
+ ``` js
15
15
// This is an inline comment
16
16
/* This is a block comment,
17
17
that can go over several lines */
18
18
```
19
19
20
20
### if / else conditions
21
21
22
- ```
22
+ ``` js
23
23
if ( a > 3 ) {
24
24
// execute if a is bigger than 3
25
25
} else {
@@ -29,7 +29,7 @@ if ( a > 3 ) {
29
29
30
30
### Logical comparisons
31
31
32
- ```
32
+ ``` js
33
33
a == b // equal
34
34
a === b // Little difference to Java: You can check for same data type as well in... to be VERY sure
35
35
a != b // not equal
@@ -38,14 +38,14 @@ a < b // smaller than
38
38
a >= b // bigger or equal
39
39
a <= b // smaller or equal
40
40
41
- // You can combine statements with logical AND ”&&” resp. the logical OR ”||”
41
+ // You can combine statements with logical AND "&&" resp. the logical OR "||"
42
42
if ( a == b && b == c ) { ... } // AND
43
43
if ( a == b || b == c ) { ... } // OR
44
44
```
45
45
46
46
### Operators and assignments
47
47
48
- ```
48
+ ``` js
49
49
// +, -, *, / // addition, substraction, multiplication and division at your fingertips...
50
50
foo = foo + 5 ; // increases the variable foo by 5
51
51
foo += 5 ; // a short version of foo = foo + 5;
@@ -58,7 +58,7 @@ Writing JavaScript for Adobe InDesign is quite a different context than Java. In
58
58
59
59
### Basic program structure
60
60
61
- ```
61
+ ``` js
62
62
// In basil.js
63
63
64
64
// @includepath "~/Documents/;%USERPROFILE%Documents";
@@ -69,8 +69,9 @@ function setup() {
69
69
70
70
function draw () {
71
71
}
72
+ ```
72
73
73
-
74
+ ``` java
74
75
// vs. Processing
75
76
76
77
void setup() {
@@ -86,13 +87,15 @@ void draw() {
86
87
87
88
### Variables and data types
88
89
89
- ```
90
+ ``` js
90
91
// In basil.js
91
92
var myNumber = 5 ; // Integers...
92
93
var myNumber = 3.0 ; // Floats...
93
- var myString = ”Hello Basil”; / Strings...
94
- var myLove = true; // and Booleans are all stored to the ”var” type
94
+ var myString = " Hello Basil" ; // Strings...
95
+ var myLove = true ; // and Booleans are all stored to the "var" type
96
+ ```
95
97
98
+ ``` java
96
99
// vs. Processing
97
100
int myNumber = 5 ;
98
101
float myNumber = 3.0 ;
@@ -104,32 +107,35 @@ boolean myLove = true;
104
107
105
108
### Defining and using functions
106
109
107
- ```
110
+ ``` js
108
111
// In basil.js
109
112
function myFunction (param1 , param2 ){
110
113
// code within the brackets has access to param1 and param2 and will be executed...
111
114
}
112
- myFunction(234, ”Some String”);
115
+ myFunction (234 , " Some String" );
116
+ ```
113
117
118
+ ``` java
114
119
// vs. Processing
115
-
116
120
void myFunction( int param1, String param2 ){
117
121
// code within the brackets has access to param1 and param2 and will be executed...
118
122
}
119
- myFunction(234, ” Some String”);
123
+ myFunction(234 , " Some String" );
120
124
```
121
125
122
126
- Functions work quite similar besides the fact that they you do not have to declare any argument or return data types.
123
127
124
128
### for-loops
125
129
126
- ```
130
+ ``` js
127
131
// In basil.js
128
132
for ( var i = 0 ; i < 100 ; i++ )
129
133
{
130
134
println ( i ); // prints 100 numbers counting upwards
131
135
}
136
+ ```
132
137
138
+ ``` java
133
139
// vs. Processing
134
140
for ( int i = 0 ; i < 100 ; i++ )
135
141
{
0 commit comments