Re-learning JS (1)--javascript object

Source: Internet
Author: User

previously in the MU class network to learn a period of JavaScript, but the study is a number of relatively basic knowledge, recently in the Web and rookie tutorials and re-learn the JavaScript, belongs to the extension on the basis of the harvest.

1. JS Array Object

(1) Array Object properties

    • Constructor: Returns a reference to the array function that created this object
    • Length: Sets or returns the number of elements in the array
    • Prototype: You can add properties and methods to an object

(2) Array object method

    • Concat (Arrayx) joins two or more arrays to return a new array
    • Join (separator) puts all the elements in the array into a string, returns a string, splits it with separator, and does not select the default ","
    • Pop () outputs and returns the last element of the array
    • Shift () deletes and returns the first element of the array
    • Push () adds one or more elements to the end of the array and returns the new length
    • Unshift () adds one or more elements to the beginning of the array and returns the new length
    • Reverse () Reverses the order of the elements in the array, changing the method to change the original array without creating a new array
    • Slice (start, end) returns the selected element (excluding the first end element) from an existing array
    • Sort (sortby) how the elements of an array are sorted using the specific method
    • Splice (Index,howmany,item1 ...) Add/Remove elements to an array index specifies the element position, howmany the number of elements deleted, item adds a new element to the array
    • ToString () converts the array to a string and returns the result, which is the same as the join () without parameters

2 , JS string Object

(1)string Object Properties

Same as Array object

(2) String Object method

    • Anchor () Creating an HTML anchor
    • CharAt (index) returns the character at the specified position
    • Concat () connection string
    • IndexOf (Searchvalue,fromindex) returns the position of a specified string value at the first occurrence of a string
    • Match () finds the matching of one or more regular expressions, returning the specified value
    • Replace (substr/regexp,replacement) replaces a substring that matches a regular expression
    • Search () retrieves the substring specified in the string, or a substring that matches the regular expression, and returns the index
    • Slice (start,end) extracts a part of a string
    • Split (Separator,howmany) splits a string into a string array
    • SUBSTR (strat,length) extracts a specified number of characters from the start subscript in a string
    • SUBSTRING (start,stop) extracts the character of a string between two specified subscripts (negative arguments are not accepted)

3. Window Object

Window object represents open windows in the browser

(1) Window object properties

    • Closed returns whether the window has been closed, returns a Boolean value, returns True when closed, only readable
    • Defaultstatus Sets or returns the default text of the window's status bar, readable and writable, which is displayed when the page loads
    • The Name property can set or return a string that holds the name of the window
    • The Status property sets or returns the text in the State Bar of the window

(2) Window object method

    • alert () displays with a specified message and an OK button warning box
    • blur () remove keyboard focus from the top-level window
    • Close () Close the browser window
    • confirm () displays a dialog box with a message and determines the button and Cancel button
    • focus () give keyboard focus to a window
    • moveby (x, y) It can be moved relative to the current coordinates of the window the specified pixel (pixels of the pixel window moved by the window X to the right)
    • moveTo (x, y) moves the upper-left corner of the window to a specified coordinate
    • open (Url,name,specs, Replace) opens a new browser window or finds a named window
    • print () prints the contents of the current window
    • prompt (out-of-box caption, box Contents) displays a dialog box that prompts the user for input, and returns a string that is entered by the user
    • Li>resizeby (width,height) Adjusts the size of the window according to the specified pixels, increasing or decreasing the
    • resizeto (width,height) resizing the window to the specified size
    • Scrollby ( Xnum,ynum) Scrolls content by scrolling the specified number of pixels (the Visible property of the window scroll bar must be set to True)
    • scrollTo (Xpos,ypos) scrolls the content to the specified coordinates
    • setinterval (code,time) calls a function or evaluates an expression according to the specified period (in milliseconds), and the function is called continuously
    • clearinterval () cancels the timer action set by the SetInterval () function
    • SetTimeout (code,time) is used to call a function or expression after a specified number of milliseconds, only once
    • cleartimeout (id_of_settimeout) cancels the SetTimeout () method

4. Screen Object

The Screen object contains information about the client display screens

Screen Object Properties

    • Availheight returns the height of the screen
    • Availwidth returns the width of the screen
    • ColorDepth returns the bit depth of the palette on the target device or buffer
    • Height returns the total height of the screen
    • Width returns the total width of the screen
    • Pixeldepth returns the color resolution of the screen

5. History Object

The History object contains the url,history that the user has visited and is part of the window object that can be accessed through the Window.history property

History Object method

    • Back () load the previous URL in the history list
    • Forward () load the next URL in the history list
    • Go () Load a specific page in the history list

Re-learning JS (1)--javascript 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.