Monday, December 22, 2014

( Twenty Fifth Week ) November 17-21 :)

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.

The parseInt() Method - This method is used to get the primitive data type of a certain String. parseXxx() is a static method and can have one argument or two.

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"
The eval() Method The eval() function evaluates or executes an argument.
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 OperatorThe conditional operator (? :) is a ternary operator (it takes three operands). The conditional operator works as follows:
  • 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

1 comment: