Client programming-JavaScript (2)

Source: Internet
Author: User
For-in Loop
It is used to traverse all user-defined attributes of an object or all elements of an array.
Predefined Functions
Eval (string) is a billboard code string that does not reference any specific object.
Isnan (test value) is used to determine whether a difficult parameter is a number. If it is not a number, true is returned, and false is returned.

There are four types of objects in javascript:
1. User-Defined Object.
2. built-in objects: objects related to data types (string number Boolean) that allow the creation of user-defined objects and composite data types (objice and array) date month Regexp used to simplify daily work
3. browser object
4. Document objects the document objects refer to the parameter Doc ument attribute.

Instance attributes: dynamically add attributes to objects in JavaScript.
VaR mystring = new string ("HELO, JavaScript ");
Mystring. simpleexample = true;
You can also dynamically add object methods.

Each object has a prototype attribute called prototype.
Robot. Prototype. hasjetpack = false;
Robot. Prototype. doaction = function () {alert ("!! 1 ");};

Class attributes (static attributes)
Robot. ismetallic = true;

Inheritance in Javascript is implemented through prototype.
Define the constructor first and then point the prototype to the instance of the parent class.
Function ultrarobot (){}
Ultrarobot. Prototype = new robot ();

Built-in JavaScript objects:
1. array object
Delete the array element Delete myarray [1]; * Delete does not change the array dimension, but sets the value to undefined.
Method: Join () expresses all the data in an array in the form of a string.
The entire element in the reverse () array is reversed, that is, the last element is switched to the position where the subscript is 0.
Pop () deletes the last element in the array and returns the result.
Push () to the last element of the array.
Concat () combines two Arrays
Slice (START, [end] gets a part of the element subscript in the array from start to end.
Valueof () returns the original value of the object.
2. String object
Charat (Num)
Charcodeat (Num) returns the value of the character at the index location specified by the num parameter.
Cancat (string) adds the string to the end
3. Math object
4. date object
Getdate, getday, gethours, getminutes, getmonth, getseconds, gettime, gettimezoneoffset (Time Zone offset information) getyear setdate ........ setyear togmtstring tolocalestring tostring parse UTC (returns milliseconds)
5. event object
6. Regexp object
7. Number object
8. function object
Arguments indicates the array of function parameters
Caller indicates calling the currently executed Function
Add new properties and methods for objects using prototype
Apply () is used to apply the methods in an object to another object.
Call (this) allows you to call methods of another object
9. Global Object

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.