Basic Javascript, evaluating a simple variable assignment/logic statement -


I'm reading through it, and I'm looking into confused with one line. The description and line in question are given:

& amp; Amp; And || Operators use short circuit logic, which means that they will execute their second operator that depends on the first. This is useful for checking the empty objects before accessing their properties:

  var name = o & amp; Amp; O.getName ();  

My confusion is here, probably the purpose of the snippet is:

  var name; If (o) {name = o.getname (); }  

However, what happens here is that the name is being assigned a boolean, and that boolean "o is present and its name is not empty". In other words, I think:

  var name = false; If (O & amp; ovatea ()) {name = true; }  

Thanks!

this is the answer


at the very top:

"Logical operators are usually used with boolean (logical) values, when they are, they return a boolean value However, Android and operators actually return the value of one of the specified operators, so these operators are used with non-Boolean values, by returning the non-boolean values. Es. "


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -