JavaScript Advanced Programming (Third Edition) Learning notes (2)

Source: Internet
Author: User
Tags local time

Fifth Chapter
    • Literal notation
var person = {    name:"a",    age:10,    5true// 数值属性名自动转换为字符串};
    • The "First name" contains a space, so you cannot use dot notation to access it, but you can person["first name"
    • Each item of an array can hold any type of data
varnewArray(20// 长度为20varnewArray("red""blue""green"// 包含三个字符串的数组
    • Each time an item is added at the end of the array, its Length property is automatically updated to reflect this change
var c = ["red""blue"]c[99"green"// c.length = 100, 访问c[2] ~ c[98], 返回undefined
  • Detects array value instanceof array for multiple global environments, cannot be judged accurately
  • The Array.isarray (value) can
  • Stack
    • Use the push () and Pop () methods of the array
  • Queue
    • Shift () and push () methods. Shift gets the first item and deletes the first item.
    • Unshift (): Adds any item to the front of the array and returns the length of the new array
  • Reverse () and sort ()
  • Concat () can create a new array based on all the items in the current array
  • Splice () method
    • Delete: Delete any number of items. Two parameters. The first represents the position of the first item to be deleted, and the second indicates the number of items to delete
    • Insert: You can insert any number of items to the specified location. Three parameters. Start position, 0, and item to insert
    • Replace: You can insert any number of items to the specified location. Three parameters.
  • IndexOf () and LastIndexOf ()
  • Iterative methods
    • Every () returns TRUE if each entry returns true
    • Filter () returns an array of true components
    • ForEach ()
    • Map () returns an array of result components
    • Some () returns true if any of the entries returns true
  • Narrowing method
    • Reduce () Reduceright () (starting from the right)
    • Iterate over all items to build a value that is ultimately returned
  • Date type
    • var now = new Date ();
    • Date.parse () accepts a character creation argument that represents a date, and then attempts to return the number of milliseconds from the corresponding date by this string
      • supported formats
        • 6/13/2004
        • January, 2004
        • Tue 2004 00:00:00 GMT-0700
        • yyyy-mm-ddthh:mm:ss.sssz
      • If the date cannot be represented, return nan
    • DATE.UTC () returns the number of milliseconds for the date
      • parameter is polygon, month (0 start), day, time, minute, second, millisecond. The first two must have the
    • Date Constructor Date.parse () and DATE.UTC (). The date and time are created based on the local time zone instead of GMT to create a
    • Date.now () returns the number of milliseconds that the date and time when the method was called
    • tolocalestring () returns the date and time in a format appropriate to the locale of the browser setting
  • RegExp type
    • var expression =/Pattern/flags
    • Three kinds of signs
      • G: Will not stop when the first match is found
      • I: Case insensitive
      • M: Multiple lines. Continues to find the next line when it reaches the end of the text
    • The primary method for regexp an object is that the exec () parameter is the string to which the pattern is applied
      • Returns an array that contains additional properties index and input
      • In global mode, each call to exec returns the next occurrence
    • True when test () is matched
function sum1(num1, num2) {    return num1 + num2}varnullsum2(55// 10 仍然可以调用
    • Understand why JS is not overloaded? Because the function defined later overrides the previous function.
    • Function Internal Properties
      • Arguments
      • Callee: Points to the function that owns the arguments object. Arguments.callee
      • Caller: Caller. Arguments.callee.caller
    • function methods
      • Apply ()
        • Two parameters, one is the scope in which the function is run, and the other is the parameter array
        • Calling a function in a specific scope
      • Call ()
        • List all the parameters.
    • Packing BASIC type
      • The base type is not an object, logically there is no method. Automatically complete a series of processing in the background
        • Create an instance of type string
        • Invoking the development method on the instance
        • Destroy this instance
"some text"s1.color"red"alert(s1.color// undefined 实例已经被销毁
var num  = 10  alert (num . ToFixed ( Num ))   
    • Number
      • ToFixed () A string representation of a numeric value that is returned by a specified number of decimal digits
      • Toexponential () formatting numeric scientific counts
      • Toprecision () may return a fixed size, possibly returning an exponent, depending on which format is most appropriate
    • String
      • Concat () Stitching strings
      • IndexOf lastIndexOf
      • Trim () Remove all whitespace from the predecessor and suffix
      • toLowerCase touppercase uppercase and lowercase conversions
      • Match pattern matches, parameter is RegExp object or regular expression, return array
      • Replace the first argument regexp or a string, and the second is a string or function
      • Htmlescape escape less than sign, greater than, and number, double quotes
      • Split separates strings based on delimiters, resulting in arrays
    • Global Object
      • URI encoding
      • encodeURI
        • For the entire URI, no special characters of the URI are encoded, such as colons,/,? #
      • encodeURIComponent
        • Used for a paragraph in a URI
      • decodeURI can only use encodeURI decoding, the same decodeuricomponent
    • The eval () parameter is a JS statement string
    • Math.random () 0~1, excluding 0 and 1
    • Selectfrom () two parameters, Min and max (inclusive)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

JavaScript Advanced Programming (Third Edition) Learning notes (2)

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.