|
ECMAScript/JavaScript
An Introduction for Programmers |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
// and the end of the line
is a comment/* and a */
is a comment
true or false
Infinity, NaN,
Number.MAX_VALUE, Number.MIN_VALUE,
Number.NaN, Number.POSITIVE_INFINITY,
Number.NEGATIVE_INFINITY
\ is the escape character and can be used to
represent special characters (e.g., \n represents
the newline character) and Unicode characters
(e.g., \u00e9 is é)
undefined
+)-)*)/)/)%)++) and Decrement (--)-)
>
<
>=
<=
==
===
!=
!==
NaN (i.e., NaN === NaN
always evaluates to false)
null == undefined evaluates to true
true becomes 1 and
false becomes 0)
&&
||
!
new Operator:
.
in Operator:
delete Operator:
[] Operator:
delete Operator:
undefined
length Property:
[] operator more than once
toString() method) and then test
| Type | Passed By | Compared By |
| boolean | Value | Value |
| number | Value | Value |
| Object | Reference | Reference |
| string | Immutable | Value |
f):
undefined
Note: This is very different from, for example, var size =
area(3,5); which executes area.
f is the same function as area and can be
used the same way.
this?
this
refers to the global objectthis
refers to the "owning" object
new Operator:
this to
refer to the object, and then invokes a functionRectangle Pseudoclass
width and height:
width
and height
area:
area
function
Rectangle Pseudoclass
hasOwnProperty() method can be
used to determine if the property is owned
by the object or its prototypein operator can be used to determine
if an object has or appears to have a property
Boolean, Number and
String).
s containing a string,
you can use methods like s.charAt(index)
n containing a number,
you can use methods like n.toString(base)