:4, [[Primitivevalue]]: "CSS3"}console.log (this = = Ele) ;//True
For the This value above, traverse the
$.each (this, function (E, ele) { console.log (e, ele);}) 0 c//1 s//2 s//4 3
Why is length and [[Primitivevalue]] not traversed? A sudden epiphany, found in JavaScript advanced programming, probably means that the internal properties of JavaScript will set the object Data proper
Graphael is a Javascript library dedicated to helping developers draw a variety of fine charts on their web pages, based on a powerful Raphael Vector Graphics library. You only need to write a few lines of simple code to create fine bar, pie, point and graph.
Graphael uses the SVG Consortium recommendation Standard and VML as the basis for creating graphics, and is a cross-browser vector graphics library t
, just because its key value is 0,1,2 ... The feeling is similar to the array, but the result of the direct traversal is as followsvar domlist = document.getelementsbyclassname (' it '); for (var item in domlist) { console.log (item, ': ' + domlist[item ]);} 0: So we need to convert the domlist to an array when we use the for in traversal of the domlistvar res = [].slice.call (domlist); for (var item in re
the properties of an object, you can use for.
Array traversal and attributes
Although arrays are objects in JavaScript, there is no good reason to use a for in loop to traverse an array.
On the contrary, there are some good reasons not to use for-in traversal arrays.
Note: The array in JavaScript is not an associativ
"}console.log(this == ele);// true
For the above this value, traverse it.
$.each(this, function(e, ele) { console.log(e, ele);})// 0 c// 1 s// 2 s// 4 3
Why is the length and [[PrimitiveValue] Not traversed? Suddenly, I found the answer in "javascript advanced programming", which means that the Enumerable in the object data attribute is set to false in the internal property of
Object itself is a collection of objects that are not, so the order of the attributes that are traversed when you iterate through the properties of an object with the For-in statement differs from the object definition.
Understanding the standards of the consortium:
As described in the ECMA-262 (ECMAScript) Third Edition, the Order of the property traversal of the for-in statement is determined by the order in which the attributes are written in the
function execution
You cannot use break or continue to skip a loop.
The output of this value in a loop is similar to the following:
console.log(this);//String {0: "C", 1: "S", 2: "S", 3: "3", length: 4, [[PrimitiveValue]]: "CSS3"}console.log(this == ele);// true
For the above this value, traverse it.
$.each(this, function(e, ele) { console.log(e, ele);})// 0 c// 1 s// 2 s// 4 3
Why is the length and [[PrimitiveValu
In $.each you want to terminate the loop, but it does not have a terminating mode such as continue or break, so try to use return to terminate, but the discovery does not jump out of the loop. In order to figure out the different types of traversal in JS, through the query to make a summary:For the convenience of examples, the existing arrays and JSON objects are as follows:1 var demoarr = [' Javascript ',
contains a subnode, which is marked with two links.
◆ As you know, you can use a JavaScript framework selection function to easily select an element through ID. In this instance, two elements have IDs, which are tr elements with IDs row-001 and row-002 respectively. Use the Prototype library to select the first tr. You can use the following code:
vartheRow=$('row-001');
In the previous chapter, you also learned that the selector is used to
is wiser to use the regular if/else structure.
(ii) JavaScript traversal object properties and methods
JavaScript uses the for in statement to traverse the properties and methods of an object. The for in statement loops through the JavaScript object, and each time the loop gets a property or method of the object.
G
The output results of JavaScript traversal of Json strings are inconsistent with those of the browser. Let's talk about what json is before introducing the body.
JSON (JavaScript Object Notation) is a lightweight data exchange format, which is called JavaScript Object Notation. One of the advantages of using JSON for
The example in this article describes the method for JavaScript array traversal. Share to everyone for your reference, specific as follows:
some: Returns true as long as there is an option in the array that satisfies the condition, returns False if none of the items meet the criteria, and does not iterate over the remaining elements.every: returns false as long as there is an option in the array t
) { console.log(e, ele);})// 0 c// 1 s// 2 s// 4 3
Why is the length and [[PrimitiveValue] Not traversed? Suddenly, I found the answer in "javascript advanced programming", which means that the Enumerable in the object data attribute is set to false in the internal property of javascript.
// View the Internal Attributes of lengthConsole. log (Object. getOwnPropertyDescriptor (this, 'length ')
What else do you know if you want to traverse the for loop? Various traversal methods of--javascriptThis is an interview in a topic, then I use the current very hot words, the whole person is ignorant, I stayed to say a sentence, I seem to only know for the loop ah. Later back to God, in fact there are many, just for the loop is the most commonly used, we often will not react to the other. Below, through the information you know and find online to do
, MAP traversal operationMap data structure. It is similar to an object and a collection of key-value pairs, but the scope of the key is not limited to strings, and the various types of values (including objects) can be treated as keys. That is, the object structure provides a "string-value" correspondence, the map structure provides "value-value" correspondence, is a more perfect hash structure implementation. If you need a "key-value pair" data stru
chain inherits is to find its own property, which is searched in the prototype chain when its own property does not exist.Sometimes we do not want this result, we just want to get the properties of the object itself (not including the properties on the object prototype chain), and each traversal to find the object's prototype chain, which will cause a performance burden.hasownproperty functionhasOwnPropertyThe function can be used to check whether th
advanced programming found the answer, presumably meaning that the internal properties of JavaScript, the object data properties in the enumerable set to False
View the internal properties of length
console.log (this, ' length ') (object.getownpropertydescriptor);
Object {value:4, Writable:false, Enumerable:false, Configurable:false}
The $ (this) in $.each is different from this, but the traversal
Copy code code as follows:
var ForEach = (function () {
Traversal of arrays and pseudo arrays
var _array_foreach = function (Array, block, context) {
if (array = = null) return;
Special handling of String
if (typeof array = = ' string ') {
Array = Array.split (');
}
var i = 0,length = Array.Length;
for (; i };
Traversal of objects
var _function_foreach = Function (object,
DOM Traversal
It is useful to look up elements based on IDs, element types, and class names, but what if you want to find elements based on where they are located in the DOM tree? In other words, you have a given element, and you want to find its parent element, one of its child elements, its last or next node sibling node. For example, use the following fragmented HTML code:
Manifest 1:html fragment (a table)
Listing 1 uses indentation to illust
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.