Home >Web Front-end >JS Tutorial >Summary of 5 years of using js
This time I will bring you a summary of 5 years of using js. What are the precautions when using js? Here are actual cases, let’s take a look.
I have been using JavaScript for 5 years. I have summarized some experiences for everyone to learn from.
1. Assigning values to undeclared variables will cause a ReferenceError to be thrown in strict mode (meaning, all variables must be defined with var, and global variables cannot be defined inside a function);
2. In strict mode, variables named eval and arguments cannot be defined, otherwise it will cause syntax error;
3. Determine whether a variable value is equal to undefined It is to formally distinguish between null object pointers and uninitialized variables;
4. As long as the variable intended to save the object has not actually saved the object, the object should be explicitly allowed to save the null value. This not only reflects null serves as a convention for object pointers, and also helps to further distinguish null from undefined;
5. Octal literals are invalid in strict mode and will cause supported Javascript engines to throw errors;
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Detailed explanation of JS debugging usage
##Steps to implement JS sending json format POST request
The above is the detailed content of Summary of 5 years of using js. For more information, please follow other related articles on the PHP Chinese website!