javascript - How does this function work in particular? -
itemprop = "text">
Can anyone tell me how this function works? I know the turner operator, so I understand this part, it checks whether the flag is true , and if not, use 2. value. But I do not understand why
flag is a boolean in the first place and why it is
true to
false and vice versa when
Chetan () is being called ...
flag = $ texte.data ('animate toggle'); $ Texte.data ('encrypt toggle', flag); $ Texte.animate ({'left': flag? '-51%': '0'})
JavaScript has values that are similar to the true and false to be evaluated as booleans, that means True and false are not the only values that can represent true or false data. For example, if $ texte .data ('alert toggle') is equal to 0 as falsy as 0 < / Code> will falsy value.
Example 1: 1000 1000 is an true value, so this output is "True "Will be:
var flag = 1000; Console.log (flag? "True": "falls"); & Gt; "True" example 2: "" "" (empty string) is a Pharsy value, so it will output "false":
var flag = ""; Console.log (flag? "True": "falls"); & Gt; "False"
converts a value for the boolean and rejects $ texte.data ('animToggle',! Flag); set animategroup data of property $ texte which was previously.
! True // Incorrect! 1000 // false! False / true! "" //right
Comments
Post a Comment