Continuation
Continuation of our JS3! :D Here it is...
Javascript provides three methods to convert the premitive data types. They are:
- String
- Numeric
- Boolean
These are also the example of the three methods.
![]() |
Sample Notepad "The parseInt Method" |
The parseFloat() Method - The parseFloat() function parses a string and returns a floating point number. This function determines if the first character in the specified string is a number. If it is, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string.
![]() |
Sample Notepad "The parseFloat Method" |
If the argument is an expression, eval() evaluates the expression. If the argument is one or more JavaScript statements, eval() executes the statements.
![]() |
Sample Notepad "The eval() Method" |
Lastly,
The Conditional Operator - The conditional operator (? :) is a ternary operator (it takes three operands). The conditional operator works as follows:
So that's it. :) Bye.
- The first operand is implicitly converted to bool. It is evaluated and all side effects are completed before continuing.
- If the first operand evaluates to true (1), the second operand is evaluated.
- If the first operand evaluates to false (0), the third operand is evaluated.
![]() |
Sample Notepad "The Conditional Operator" |
So that's it. :) Bye.
Thanks for reading! :)
Questions? Free to ask. :D
This comment has been removed by the author.
ReplyDelete