Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the seven data types of javascript?

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What are the seven data types of javascript? in view of this question, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Foreword:

Each major language will have basic types, such as python,java,c series, the existence of basic types is indispensable, it is like integers in our lives, Chinese characters in Chinese, it is to express these, think about it is quite important, then js has five common basic data types are: String,Number,Boolean,Undefined,Null, there are two common complex types Object,Symbol.

Details: sequence type nickname range common methods to introduce 1String strings

.toString () converts an object to a String type

Length attribute, which is used to obtain the length string type of String characters. It is mainly used to represent string types such as English and Chinese. The 2Number numeric type of the content wrapped in single quotation marks''or double quotation marks''or double quotation marks "" determines whether it is a numeric type of number type, whether it is a decimal or integer negative number, etc., and uses the number type to represent 3Boolean Boolean values.

There are only two values. True,false,true means true false and false 4Undefined is undefined.

Indicates that only the type is declared, but the undefined value 5Null is null

Indicates that the object reference is a null6Object object

Object is a value of type key-value contained in curly braces, called the object 7Symbol unique value

Used to represent unique values, different values exercise: / / String let str = "hello js"; console.log (str.toString); / / print: hello js console.log (str.length); / / print: 8 console.log (str.substr (1)); / / method: split and print the string: ell console.log (str.split (')) / / method: group print according to the specified parameters ['hello'' js'] / / Number let num = 123; console.log (! isNaN (num)); / / determine whether it is NaN, if not, the value / / Boolean let flag = false; if (flag) {/ / print the result as false console.log ("result is true") } else {console.log ("result is false");} / / Undefined let d; let val = `when an object is not assigned, the current value is: ${d}`; console.log (val); / / print: when an object is not assigned, the current value is: undefined / / Null let a = null let nul = a; console.log (nul) / / print: null / / Object let obj1 = {"name": "Zhang San", "age": 24} / / Symbol let sy = Symbol ("1"); if (sy = = Symbol ("1")) {/ / print: result is false console.log ("result is true");} else {console.log ("result is false") } the answers to the questions about the javascript seven big data types are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report