In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you what js data types are, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Js data types are: string (String), number (Number), Boolean (Boolean), null (Null), undefined (Undefined), Symbol, object (Object), array (Array), function (Function).
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Like other languages, Javascript scripting language has its own basic data types, expressions and arithmetic operators, and a basic programming framework for programs.
What are the js data types?
JavaScript data type:
Value type (basic type): string (String), number (Number), Boolean (Boolean), null (Null), undefined (Undefined), Symbol.
Reference data types: object (Object), array (Array), function (Function).
Note: Symbol is a new primitive data type introduced by ES6 that represents a unique value.
JavaScript has dynamic types:
JavaScript has dynamic types. This means that the same variable can be used as different types:
Example
Var x; / / x is undefinedvar x = 5; / / now x is a number var x = "John"; / / now x is a string
JavaScript string
A string is a variable that stores characters, such as "Bill Gates".
The string can be any text in quotation marks. You can use single or double quotation marks:
Var carname= "Volvo XC60"; var carname='Volvo XC60'
You can use quotation marks in a string, as long as they do not match the quotation marks that surround the string:
Var answer= "It's alright"; var answer= "He is called 'Johnny'"; var answer='He is called "Johnny"'
JavaScript digit
JavaScript has only one numeric type. Numbers can be decimal or not:
Var x1 to 34. 00; / / write var x2 to 34 with decimal point; / / write without decimal point
Very large or very small numbers can be written by scientific (exponential) counting:
Var yearly 123e5; / / 12300000var zonal 123eMur5; / / 0.00123
JavaScript Boolean
Boolean (logical) can only have two values: true or false.
Var true reality var y=false
JavaScript array
The following code creates an array named cars:
Var cars=new Array (); cars [0] = "Saab"; cars [1] = "Volvo"; cars [2] = "BMW"
Or
(condensed array): var cars=new Array ("Saab", "Volvo", "BMW")
Or
(literal array): var cars= ["Saab", "Volvo", "BMW"]
The array subscript is based on zero, so the first item is [0], the second is [1], and so on.
JavaScript object
Objects are separated by curly braces. Inside the parentheses, the properties of the object are defined in the form of name and value pairs (name: value). Properties are separated by commas:
Var person= {firstname: "John", lastname: "Doe", id:5566}
The object (person) in the above example has three properties: firstname, lastname, and id.
Spaces and line breaks don't matter. Declarations can span multiple lines:
Var person= {firstname: "John", lastname: "Doe", id: 5566}
Object properties can be addressed in two ways:
Name=person.lastname;name=person ["lastname"]
Undefined and Null
The value Undefined indicates that the variable does not have a value.
You can empty a variable by setting its value to null.
Cars=null;person=null
Declare variable types
When you declare a new variable, you can use the keyword "new" to declare its type:
Var carname=new String;var x = new Number;var y = new Boolean;var cars= new Array;var person= new Object; what are the js data types mentioned above? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.