JavaScript. What does this expression mean: " var a = b === c && d; " -
// define walk_the_dom function visits every // node of tree in html source order, starting // given node. invokes function, // passing each node in turn. walk_the_dom calls // process each of child nodes. var walk_the_dom = function walk(node, func) { func(node); node = node.firstchild; while (node) { walk(node, func); node = node.nextsibling; } }; // define getelementsbyattribute function. // takes attribute name string , optional // matching value. calls walk_the_dom, passing // function looks attribute name in // node. matching nodes accumulated in // results array. var getelementsbyattribute = function (att, value) { var results = []; walk_the_dom(document.body, function (node) { var actual = node.nodetype === 1 && node.getattribute(att); if (typeof actual === 'string' && (actual === value || typeof value !== 'string')) { results.push(node); } }); return results; }; i don't understand line of code mean:
var actual = node.nodetype === 1 && node.getattribute(att); how explain kind of expression?
a = b === xxx && yyy thanks.
this combination of short-circuiting , fact javascript returns final value of statement. it's same as:
if (b === xxx) { = yyy; } else { = false; } read more here: http://en.wikipedia.org/wiki/short-circuit_evaluation , https://developer.mozilla.org/en/javascript/reference/operators/logical_operators#short-circuit_evaluation
Comments
Post a Comment