Do b\s project has more than a year, oneself is to do backstage out, to write JS aspect may also follow the previous idea, think is oo language after all. However, from the last project to eat some of the hardship, let me decide to calm down to the JS book to see. This "JavaScript language essence" is recommended to me, the reason why I chose this book, because I know the importance of code quality (think of the code I wrote before, really want to go back to rewrite), the more code written, I would like to use more concise code to implement the function, This, of course, requires more in-depth understanding of JS design Patterns and the original rational things. Many people say that JS is simple, because the language is not very understanding, can also use it to work, think is the general Oo language. In fact, JS has its own unique characteristics, such as closures, prototypes, weak types, dynamic objects and so on. Next, I would like to read this book when I think it is more important concept to do a record and comb, I hope I can warm and know new, but also hope to share with others.
1. JavaScript has only one numeric type, which is represented internally as a 64-bit floating-point number (it does not separate integers, so 1 and 1.0 are the same); Nan is a numeric value that represents a result of an operation that does not produce a normal result, and Nan is not equal to any value, including itself;
2, JS is treated as a false case, which is very effective in making if judgment, can make your code looks very concise: false, null, undefined, empty string "", the number 0, the number of Nan, the six cases will be JS considered false;
3, when using the for...in statement to do the loop, pay special attention, this will poll all properties, including the prototype chain properties. You can use Object.hasownproperty () to determine whether a property is from a member of an object or from a prototype chain;
4, JavaScript simple data types include: Number, String, Boolean, null, undefined, all others are objects. Note here that the string is not an object and is somewhat different from other OO languages;
5. JavaScript functions have four invocation patterns: Method invocation mode, function call pattern, constructor invocation pattern, and apply invocation pattern, which differ on how to initialize the key parameter this:
Method invocation Pattern: A function is saved as a property of an object, and we call it a method that is bound to the object when a method is called;
Function call Pattern: When a function is not a property of an object, it is called as a function, this mode, this is bound to the global object;
constructor invocation pattern: If called with new in front of a function, then secretly creates a new object linked to the function's prototype member, and this is bound to the new object;
Apply invocation mode: The Apply method accepts two parameters, the first one is the value to bind to this, and the second is an array of arguments;
6, when the function is called, will get a arguments (similar to an array of objects), the function can access all the parameters it is called to pass to its list of arguments, (because JS defines the function, do not specify the parameters, but the call when the argument, which is legitimate.) Arguments can access all parameters passed to the function)
Let's do it today.
The essence of JavaScript language notes