JavaScript's String and Boolean type

JavaScript data types of String and boolean


String

String type is used to represent sequences of characters from zero to a plurality of 16-bit Unicode characters, i.e., the string. The string may be represented by double quotation marks ( ") or a single quote ( ')

toString()与String()

  • Syntax: str.toString ()
  • Function: Convert a string str
  • Returns: a copy of str
  • Parameters: str is the content to be converted, can be a numeric, boolean, string objects, and
  • Note: I do not know whether to be converted value is null or undefined circumstances, you can still use the String () function, which can be any type of value to a string

Boolean

Type used to represent true and false, that is true if true, false false representation

Type Conversion

  1. All numbers except 0, converted to a boolean are true
  2. In addition to "" (empty string) all the characters, are converted to a boolean to true
  3. null and undefined is converted to a boolean is false
Published 15 original articles · won praise 16 · views 216

Guess you like

Origin blog.csdn.net/qq_43133192/article/details/104916867