why do some people store a var within another var?
For example:
var checked = $("#filterControls :checkbox:checked");
var arr = checked
A more expansive view of the code below.
var checked = $("#filterControls :checkbox:checked");
if (checked.length) {
rows.hide(200);
var arr = checked
.map(function() {
return "." + $(this).val();
})
.get();
var selector = arr.join("");
$(selector).show(200);
}
You got a wrong idea about the map
function. The map
function is immutable, but it returns the modified entries. Because of that you have to assign it to a new value. So checked
has the unmodifed values and arr
has the values which were modified by map
-function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.