Home > Web Front-end > JS Tutorial > Detailed explanation of the five data types in Javascript_Basic knowledge

Detailed explanation of the five data types in Javascript_Basic knowledge

WBOY
Release: 2016-05-16 16:24:25
Original
1224 people have browsed it

Undefined

Undefined. There is only one value undefined

Null

There is only one value, null

Boolean
In JavaScript, as long as the logical expression does not return undefined or null, it is true.

Copy code The code is as follows:

if(3) true
if(null) false
if(undefined) false

Number

String

The char type does not exist in JavaScript.

String definitions can use single quotes or double quotes.

Copy code The code is as follows:




                                            



typeof is a unary operator used to obtain the data type of a variable
There are five return values:
undefined, boolean, number, string and object. The first four are easy to understand. The last object is something that programmers have no way of judging, and only object

is returned in general.

In JavaScript, if a function does not declare a return value, it will return undefined by default.

If a return value is declared, then whatever is actually returned is what is returned.

undefined is derived from null, so it returns true when compared

alert(undefined==null);//true

Forced type conversion

In JavaScript, there are three types of casts:

Boolean(value)

Number(value)

String(value)

Copy code The code is as follows:



                                            




In JavaScript, all objects inherit from the Object object.

Generate using new method.

Some methods in js can be enumerated, but some cannot.

Using js built-in methods to determine whether it can be enumerated.



                                            





Enumerate properties of custom types

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template