JavaScript Data Type Conversion Flashcards
Learn about JavaScript data type conversion (7 cards)
JavaScript is a dynamically typed language, what does this mean?
This means you don’t have to specify the data type of a variable when you declare it. It also means data types are converted as-needed during script execution.
How would you add a numeric value into a string?
You can add a numeric value into a string using the + operator.
What are the three ways to convert strings into numbers?
The three ways to convert strings to numbers are:
- parseInt()
- parseFloat()
- Number()
What does parseInt do?
The parseInt function converts its first argument to a string, parses that string and then returns an integer or NaN.
What parameters does parseInt accept?
parseInt accepts a string as its first parameter and radix as its second parameter.
What does parseFloat do?
parseFloat parses a string argument and returns a floating point number.
What does Number do?
Number converts the passed argument to a numeric value.