Summary of the main points of the JavaScript apocalypse

Source: Internet
Author: User

Preface: This article is reading "JavaScript revelation" after a reading note, the main points of the book is a summary, not the original content Oh. To learn more about the content, read the original book.

  1. Objects are made up of named properties that store values.
  2. Almost all objects in JavaScript can behave like objects. A complex value is an object, and the original value can also be considered an object.
  3. objects are created by calling the constructor using the new keyword or by using a literal expression.
  4. A constructor is an object (function () object), so objects are created in JavaScript.
  5. JavaScript provides 9 native constructors: Object (), Array (), String (), number (), Boolean (), Function (), Date (), REGEXP (), and error (). When needed, String (), number (), and Boolean () constructors can provide raw values and object wrappers so that when the original values are treated as objects, they can behave like objects.
  6. null, Undefined, "string", 10, true, and false are the original values, without object properties, unless they are considered objects.
  7. When invoking the native constructor provided by JS using the New keyword, an object is created, called a "complex object" or "Reference object."
  8. Primitive forms of NULL, undefined, "string", 10, true, and false do not have object properties, unless they are used as objects, and JavaScript creates temporary wrapper objects in the background, which can behave like objects.
  9. The original values are stored by value and are copied by literal means when copied. On the other hand, complex object values are stored by reference and copied by reference.
  10. When the values of the original values are equal, they are equal, whereas complex objects are equal only if the same values are referenced. That is, when you point to the same object, a complex value is equal to another complex value.
  11. Because of complex objects and referenced attributes, JavaScript objects have dynamic properties.
  12. JavaScript is mutable, which means that native objects and user-defined object properties can be manipulated at any time.
  13. You can get, set, and update object properties by using dot notation or parenthesis notation.
  14. When looking for an object, the lookup chain looks at the properties of the object reference, and if it is not found, continues on the prototype property of the constructor, and if it is still not found, because the prototype has an object value and is created by the object () constructor, the object () The Ptototype property of the constructor is searched. If it is not yet found, determine the property value to undefinded.
  15. Replacing the Ptototype property with a new object removes the default constructor property and does not update the previously defined instance, only the subsequent instance is affected by the time the Ptototype property is replaced from the newly object.
  16. The prototype lookup chain shows how inheritance is implemented in JavaScript.
  17. Because the object property lookup chain exists, all objects inherit from object (), so the prototype property is itself an object ().
  18. A JavaScript function is a class citizen: A function is an object that has properties and values, and there is always a return value, either explicit or undefined.
  19. Functions are called before they are named, and functions are promoted.
  20. When you use the This keyword inside a function, it is a common method for referencing the object that contains the function.
  21. The value of this can be determined at run time based on the context in which the function is called.
  22. Using the This keyword in a nested function references a global object, and you can use another variable to cache the This object to resolve the problem.
  23. Use the This keyword within the global scope to refer to the global object.
  24. JavaScript takes a function as a method to create a unique scope.
  25. JavaScript provides a global scope, and all JavaScript code is within this scope.
  26. JavaScript has no block-level scope, only global scope, local scope (function scope), and eval scope.
  27. The function creates a scope chain to resolve the variable lookup problem.
  28. A scope chain is created based on how code is written, not on the context in which the calling function resides. That is, the definition of a function determines the scope, not when it is called. This allows the function to access the scope at which the code was originally written, even if it was called from a different context, which is called a closure.
  29. function expressions and variables that are defined inside the function will become global properties if they are not declared with Var. However, function statements inside function scopes are still defined within the scope that is made when the code is written.
  30. Functions and variables defined in the global scope (without using Var) become properties of the global object.
  31. Functions and variables defined in global scope (using VAR) become global variables.
  32. The Boolean () constructor takes a parameter and converts it to a Boolean value. Any valid JavaScript value except 0,-0, NULL, FALSE, NaN, undefined, and empty string ("") will be converted to true.
  33. A Boolean object that is created by the Boolean () constructor (relative to the original value) is an object, and the object is converted to true, and if a non-Boolean value needs to be converted to a Boolean value, only the Boolean () constructor without the new keyword is used, and the returned value is a raw value. Instead of a Boolean object.
  34. Null is an explicit expression that the object property does not contain a value.
  35. Undefined the first usage scenario is declaring a variable, but not specifying a value, and the second is that the object property that you are trying to access is not defined and does not exist in the prototype chain.
  36. The math () object contains static properties and methods, which are built into JavaScript instead of creating instances based on the math () constructor.
  37. Math is a one-time object that holds static properties and methods, does not create a method for an instance of math, and many of its properties are constants that cannot be changed.

Summary of the main points of the JavaScript apocalypse

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.