5.5.4 for/in
for (variable in object)
statement
for(var i = 0; i < a.length; i++) // Assign array indexes to variable i
console.log(a[i]); // Print the value of each array element
for(var p in o) // Assign property names of o to variable p
console.log(o[p]); // Print the value of each property
5.7.1 with
with (object)
statement
in non-strict mode: avoid using it whenever possible
document.forms[0].address.value
with(document.forms[0]) {
// Access form elements directly here. For example:
name.value = "";
address.value = "";
email.value = "";
}
避免使用with语句,你可以使用下面的方法:
var f = document.forms[0];
f.name.value = "";
f.address.value = "";
f.email.value = "";
范围链只是用来查找标识的,而不是创建新的的,考虑下面的语句:
with(o) x = 1;
如果o有一个x属性,那么这个属性将赋值1.如果没有的话,那么不会给o创建一个x属性,x相当于在with语句的外面,可能会创建一个本地或者全局的属性。
分享到:
相关推荐
Chapter 5 Statements Chapter 6 Objects Chapter 7 Arrays Chapter 8 Functions Chapter 9 Classes and Modules Chapter 10 Pattern Matching with Regular Expressions Chapter 11 JavaScript Subsets and ...
Chapter 5 Statements Chapter 6 Objects Chapter 7 Arrays Chapter 8 Functions Chapter 9 Classes and Modules Chapter 10 Pattern Matching with Regular Expressions Chapter 11 JavaScript Subsets and ...
Chapter 5 Statements Chapter 6 Objects Chapter 7 Arrays Chapter 8 Functions Chapter 9 Classes and Modules Chapter 10 Pattern Matching with Regular Expressions Chapter 11 JavaScript Subsets and ...
02 - Financial Statements, Cash Flow, and Taxes
Chapter 13 SQL Statement Syntax.pdf 官方:https://dev.mysql.com/doc/refman/5.7/en/sql-syntax.html
Chapter 3 Statements Chapter 4 Objects and Classes Chapter 5 Core Classes Chapter 6 Inheritance Chapter 7 Error Handling Chapter 8 Numbers and Dates Chapter 9 Interfaces and Abstract Classes Chapter ...
Chapter 5: Arrays and Records Chapter 6: All About Strings Part II Chapter 7: Objects Chapter 8: Inheritance Chapter 9: Handling Exceptions Chapter 10: Properties and Events Chapter 11: Interfaces ...
Chapter 5. A Tour of C++: Concurrency and Utilities Part II: Basic Facilities Chapter 6. Types and Declarations Chapter 7. Pointers, Arrays, and References Chapter 8. Structures, Unions, and ...
Chapter 5: Selection Statements 99 Chapter 6: Iteration 117 Chapter 7: Functions 144 Chapter 8: Arrays 167 Chapter 9: Pointers 197 Chapter 10: C-Strings 231 Chapter 11: Classes and Objects-1 261 ...
Chapter 5. Expressions and Operators Chapter 6. Statements Chapter 7. Functions Chapter 8. Arrays Chapter 9. Pointers Chapter 10. Structures and Unions and Bit-Fields Chapter 11. Declarations Chapter ...
Chapter 5. Expressions and Operators Chapter 6. Statements Chapter 7. Functions Chapter 8. Arrays Chapter 9. Pointers Chapter 10. Structures and Unions and Bit-Fields Chapter 11. Declarations Chapter ...
Cap 5 - Chapter 5 Decisions: 47 Cap 6 - Chapter 6 Loops: 58 Cap 7 - Chapter 7 Errors: 80 Cap 8 - Chapter 8 Subprograms and Modules: 86 Cap 9 - Chapter 9 Arrays: 108 Cap 10 - Chapter 10 Advanced Input ...
Chapter 5. Basic Concepts of Operating Systems Chapter 6. The Internet Chapter 7. Introduction to Algorithms and Programming Concepts Chapter 8. Basics of C Chapter 9. Input and Output Chapter 10. ...
Chapter 5 : Control Statements:Part II
Chapter 5 Methods Chapter 6 Arrays and ArrayLists Chapter 7 Introduction to Classes and Objects Chapter 8 Classes and Objects: A Deeper Look Chapter 9 Object-Oriented Programming: Inheritance Chapter ...
Chapter 5. Standardization: ECMAScript Chapter 6. Historical JavaScript Milestones Part III: JavaScript in Depth Chapter 7. JavaScript’s Syntax Chapter 8. Values Chapter 9. Operators Chapter 10. ...
Chapter 5 - Handling ADO.NET Events Chapter 6 - Integrating XML with ADO.NET Chapter 7 - Data Binding and Windows Forms Data-Bound Controls Chapter 8 - Constraints and Data Relations Chapter ...
Chapter 42: Global Functions and Statements. Part V: Putting JavaScript to Work. Chapter 43: Data-Entry Validation. Chapter 44: Scripting Java Applets and Plug-ins. Chapter 45: Debugging Scripts. ...
Chapter 8: Boolean Logic & Conditional Statements Chapter 9: Math Operators Chapter 10: Classes Chapter 11: Inheritance Chapter 12: Polymorphism Chapter 13: About Version Control Chapter 14: Git ...
There are quite a number of ...Chapter 5: Handling and Logging Exceptions Chapter 6: Data Objects Chapter 7: Authentication Chapter 8: Multifunctional Interfaces