Home > Web Front-end > JS Tutorial > body text

Does javascript have data types?

醉折花枝作酒筹
Release: 2023-01-07 11:44:33
Original
2413 people have browsed it

JavaScript has data types, which are: 1. Primitive data types, object, number, string, boolean, null and undefined; 2. Reference data types, Array, Date and function of object type.

Does javascript have data types?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Javascript's data types are divided into two categories: original data types and reference data types

Original data type:

Object

## Number

String

# Boolean

NULL

## Undefined

## 引 The data type:

Object type Array, Date, Function

js variables

[1] Declaration of variables in js

v variable name = value;

## [2] The use of variables in js pay attention to pay attention to The names of the variables in

# A, JS are consistent with the naming of Java's bidders.

B, JS variable names can be repeated, but the name of the latter will cover the name of the former

# C and JS. It is not recommended that you write this way.

Commonly used type detection methods are: typeof, instanceof

Liezi:

var age = 13;
alert(typeof(age));    //浏览器弹框内容:number
var name = '五宝';
alert(typeof(age));    //浏览器弹框内容:string    注意,JavaScript没有char类型
Copy after login
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script>
            var  a =1;
            var  b =null;
            var  c ="你好";
            var  d=true;
            var  e=new  Date();
            var  f=&#39;5&#39;;
            var  z=1.32;
            var  a=123;
            alert(typeof(e));    //浏览器弹框出现  object
        </script>
    </head>
    <body>
    </body>
</html>
Copy after login

[Recommended learning:

javascript advanced tutorial]

The above is the detailed content of Does javascript have data types?. For more information, please follow other related articles on the PHP Chinese website!

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