This page provides a brief overview of the JavaScript programming language, the language used
to program Karel.
Look here for an overview of Karel's world and what he can do.
Look here for a reference guide that describes the details of the commands
and functions Karel understands.
Basics:
- White Space and Line Breaks
-
JavaScript ignores spaces, tabs, and newlines except those that appear within strings (see below).
This means you can (and should!) use formatting such as indentation and spacing to make your
programs more readable to humans.
- Comments
-
Any text between // and the end of a line is treated as a comment and is ignored.
Any text between /* and */ is treated as a comment and is ignored.
You should use comments generously within your code to explain what it is doing.
- Case Sensitivity
-
JavaScript is a case-sensitive language. This means that language keywords, variables,
function names, and other identifiers much always be typed with a consistent capitalization
of letters. In other words, "turnleft()" is not the same as "turnLeft()" (notice the capital 'L').
- Semicolons
-
Statements should (but do not strictly have to) end with a semicolon (;).
- Data Types
-
JavaScript supports values with one of three primitive data types: Numbers, Strings, and Booleans (true or false).
JavaScript does not distinguish between integers and floating point numbers.
JavaScript also supports two special "data types", null and undefined, each
of which defines only a single value.
JavaScript also supports the composite datatypes Object and
Array.
- Variables
-
JavaScript variables, like variables in any other programming language, can be thought of as named containers.
You can place data into these containers (called "assigning a value to a variable") and take data out of them
(called "getting the value of a variable"). JavaScript variables are defined with the var keyword.
Unlike many other languages, JavaScript variables are not of a certain type. The specific value contained
within a variable is of a specific type, but a variable may hold an integer at one point and then a string at
another point (although this is rare).
- Variable Scope
-
MORE HERE
- Reserved Words
-
The following are all reserved words in JavaScript:
abstract, boolean, break, byte, case, catch, char, class, const, continue, debugger, default, delete, do, double,
else, enum, export, extends, false, final, finally, float, for, function, goto, if, implements, import, in,
instanceof, int, interface, long, native, new, null, package, private, protected, public, return, short,
static, super switch, synchronized, this, throw, throws, transient, true, try, typeof, var, void,
volatile, while, with
- Operators
-
MORE HERE
- MORE HERE
-
MORE HERE
Conditionals / Branching:
Repeating Things: