@daixuan1996
2015-03-14T23:46:23.000000Z
字数 2288
阅读 700
Chapter1
Chapter2
Better way to place JavaScript:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
...
<script src="test.js"></script>
<!-- type="text/javascript" is unnecessary -->
</body>
</html>
JavaScript is a interpreted language, which interpreted by the web browser.
Comment:
// comment1 -line
/* comment2 - block*/
JavaScript is a weakly typed language.
Data Type
Array, very free.
var a = Arrary(args); // arg is optional
var b = [[1, 2, 3], "what", true]; // free, numeric array
var c = Array(); // associative array
c["name"] = "H";
c["year"] = 1999;
Object, a group of multiple values under the same name. Each one of the value is a property of the object.
var a = Object();
a.name = "H";
a.year = 1999;
var b = { name: "H", year: 1999};
var c = {};
c.pro = a; // c.pro.name == "H"
alert()
.var
to declare a local variable.Objects, a self-contained collection of data, which comes in two forms: properties and methods.
An instance is an individual example of a generic object.
var you = new ObjectName;
User-defined Objects
Native Objects
Array
length
sort()
Date, can be used to store and retrieve information about a specific date and time.
getDay()
, getHours()
, getMonth()
Math
round()
Chapter3