1.1 Core JavaScript
This section is a tour of the JavaScript language.
Types, Values, and Variables
// variable is a symbolic name for a value. x = null; // Null is a special value that means "no value". |
objects and arrays
// JavaScript's most important data type is the object. |
2.1 Character Set
2.1.1 Case Sensitivity
E.x. online, Online, OnLine, and ONLINE are four distinct variable names.
2.3 Literals
{ x:1, y:2 } // An object initializer
[1,2,3,4,5] // An array initializer
2.4 Identifiers and Reserved Words
In JavaScript, identifiers are used to name variables andfunctions and to provide labels for certain loops in JavaScript code. A JavaScript identifier must begin with a letter, an underscore (_), or a dollar sign ($).
These are all legal identifiers:
i
my_variable_name
v13
_dummy
$str
3.1 Numbers
Unlike many languages, JavaScript does not make a distinction between integer values and floating-point values. All numbers in JavaScript are represented as floating-point values.
3.1.5 Dates and Times
var then = new Date(2010, 0, 1); // The 1st day of the 1st month of 2010
var later = new Date(2010, 0, 1, 17, 10, 30);
// Same day, at 5:10:30pm, local time
var now = new Date(); // The current date and time
3.10.2 Variables As Properties
If you use var to declare the variable, the property that is created is nonconfigurable (see §6.7), which means that it cannot be deleted with the delete operator.
var truevar = 1; // A properly declared global variable, nondeletable.
fakevar = 2; // Creates a deletable property of the global object.
this.fakevar2 = 3; // This does the same thing.
delete truevar // => false: variable not deleted
delete fakevar // => true: variable deleted
delete this.fakevar2 // => true: variable deleted
4.2 Object and Array Initializers
[] // An empty array: no expressions inside brackets means no elements
[1+2,3+4] // A 2-element array. First element is 3, second is 7
4.3 Function Definition Expressions
// This function returns the square of the value passed to it.
var square = function(x) { return x * x; }
6.4 Testing Properties
var o = { x: 1 }
"x" in o; // true: o has an own property "x"
"y" in o; // false: o doesn't have a property "y"
"toString" in o; // true: o inherits a toString property
作者:石世特
出处:http://www.cnblogs.com/TivonStone/
希望本文对你有所帮助,想转随便转,心情好的话给我的文章留个链接.o(. .)o