This week, we've just continue our works, everything about JavaScript III.
Now, I shared an information about what I have learned in this week.
Logical Operators- allow you combine the relational operators into more powerful expressions for testing conditions and are most often used in if statements.
The three logical operators are the logical AND, logical OR, and logical NOT. The symbol for AND is &&, the symbol for OR is ||, and the symbol for NOT is !.
The && Operator (Logical AND) - returns the Boolean Value true if both operands are true and returns false otherwise. The operands are implicitly converted to type bool prior to evaluation, and the result is of type bool. Logical AND has left-to-right associativity.
The || Operator (Logical OR) - combines two Boolean variables or expressions and returns a result that is true if either or both of its operands are true.
The ! Operator (Logical NOT) - it reverses the value of a Boolean expression.
The Logical (Boolean) Operator - the Boolean value true is assigned to the variable answer.
The Conditional Operator - is called a ternary operators because it requires three operands.
Format: conditional expression ? expression : expression
Number, String, or Boolean? Datatype Conversion
The parseInt () Method - converts a string to a number. It starts parsing at the beginning of the string and returns all the integers until it reaches a non-integer and then stops parsing. If the the string doesn't begin with an integer, NaN (not a number) is returned.
The ParseFloat () Method- is just like the parseInt () method except that it returns a floating-point number.
The Eval Method- evaluates a string of JavaScript statements and evaluates the whole thing as a little program returning the result of the execution. If there is no result, undefined is returned.
Note: if you have any questions, feel free to comment in the lower box. Thank you!
Ciao!
No comments:
Post a Comment