|
||||||||
JavaScript: Basic Statements and DeclarationsLiteralsNumbers: Same as most languages, 4, 3.33333, etc. Strings: Again similar to many languages, "Hi, How are you today?" Boolean: Boolean values can either be true or false. We define boolean values by declaring new Boolean(). What we put in the parenthesis, make the boolean value either true or false.
VariablesUnlike Java and most other languages there are no declared types for local variables, class variables. While JavaScript has in some sense the notion of Objects and Classes (we will discuss next), you do not need to declare an object you simply create it as we will see later. This can be quite confusing for the experienced programmer.....and makes code (I think) hard to read. What is even stranger is that you can change the type of data stored in a variable at any time in the code. Instance Variables:
Return TypesUnlike other languages there is no return type for a function (we will discuss functions later)
ArraysSimply define a variable to be an array and call the built-in JavaScript class Array's constructor as follows:
OperatorsThese are basically the same as in C/C++. See your book for details. |
||||||||
© Lynne Grewe |