Chapter 1 of JavaScript For Beginners page 1/2

Source: Internet
Author: User

JavaScript Data Type
Number: integer, float type
String: String type data. JavaScript does not distinguish a single character from a String,
Any character or string can be enclosed in double or single quotes.
Boolean: Boolean
Undefined: Undefined type, used for variables or object attributes that do not exist or are not assigned an initial value, such:
Var name; the name is Undefined.
Null: Null. Generally, the Undefined and Null types are treated similarly.
Function: Function. You can use the new operator and constructor Function () to dynamically create the required Function and add the Function body to it. For example:
Var myFunction = new Function ()
{
Staments;
};
Combination Type: Array, Object
Array: An Array type, containing a sequence of basic and combined data. An Array is essentially an Array object.
Var score = [56, 34, 45];
Object: Object type. An Object can be a combination of basic and composite data,
And the object's members are the attributes of the object, and the object's member functions are the object's methods.

Operators in JavaScript:
The keyword corresponding to the null operator is "void", which defines an expression, but this expression does not return any value.
Object OPERATOR: vertex operator, new-selector, delete operator, and () operator.
Typeof OPERATOR: used to indicate the Data Type of the operand. the return value type is a string. For example:
Var myString = typeof (data );

With object operation statement: simplifies the reference process of Object Attributes and methods. Its syntax structure is as follows:
With (object)
{
Statements;
}

For... in: Performs cyclic operations on objects. for example:
For (variable name in object name)
{
Statements;
}

Function: defined as follows:

Function funcName ([parameters])
{
Statements;
[Return expression;]
}

Global functions: many global (built-in) functions are defined in JavaScript and can be called directly during programming.
ParseInt (): converts a string to an integer.
ParseFloat (): converts a string to a floating point number.
Escape (): converts some special characters into ascii codes.
Unescape (): converts an ascii code to a character.

All data types and arrays in JavaScript scripts can be treated as objects,
Functions are no exception. You can use the new operator and Function object constructor Function ()
To generate the function of the specified rule. The basic syntax is as follows:
Var funcName = new Function (arguments, statements ;);

JavaScript event processing:
JavaScript scripts can process events through anonymous functions, explicit declarations, and manual triggers.
Anonymous functions:
Document. MyForm. MyButton. onclick = new Function ()
{
Alert ("Your Have clicked me! ");
}

Manually triggered:
Trigger an event using other elements instead of user actions, as shown in the following figure:

<Script language = "JavaScript" type = "text/javascript">
<! --
Function MyImageA ()
{
Document. all. MyPic. src = "2.jpg ";
}
Function MyImageB ()
{
Document. all. MyPic. src = "1.jpg ";
}
-->
</Script>

<Script language = "JavaScript" type = "text/javascript">
<! --
// The function is not called by other controls.
Document. all. MyPic. onmouseover = MyImageA;
Document. all. MyPic. onmouseout = MyImageB;
-->
</Script>

Relationships between top-level objects:
When a webpage is opened, the following objects are generated: window-> screen, navigator, location, history, frames [], document.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.