Javascript: Bent Dalgaard Larsen
Javascript: Bent Dalgaard Larsen
BentDalgaard
Larsen
Overview
• SimpleJavaScript
syntax
• Different
waysto
accesstheVRML
scene
• Importantobjects
Syntax - 1
• Verymuchlike C/C++/Java
• Noneedtodefine
variables
– Although
thespecificationsaysthat var should
buesed
• Types
– Numbers(integers,float),
booleans,
strings,objects,
null,undefined
• Automatic
conversion
– A=”a”
+9=
”a9”
Syntax - 2
• Arithmetic
– + * / % ++ -- -
• Comparison
– == != > >= < <=
• Boolean
– && || !
• Strings
– ’hello’ + ’world’
Syntax - 3
if (condition) { statements; }else{ statements;}
switch (expression) {
case ’label’:
statement;
break;
default:
statements;
}
for (initial-statement;test;increment)
{statements}
Syntax - 4
do {
statements;
} while (condition);
while (condition) {
statements;
}
Canbceombinedwith:
break;
continue;
Syntax - 5
for (variable in object) {
statements;
}
with (object) {
statements;
}
Comments:
// comment type 1
/* comment type 2 */
AccessingVRML
scene -1
DEF MyTrans Transform { ... }
Browser.getName();
Browser.getVersion();
Browser.getCurrentSpeed();
Browser.getCurrentFrameRate();
Browser.getWorldURL();