In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "what are the data types of WeChat Mini Programs WXS language", with detailed content, clear steps and proper handling of details. I hope that this article "what are the data types of WeChat Mini Programs WXS language" can help you solve your doubts.
Data type
The WXS language currently has the following data types:
Number: numeric
String: string
Boolean: Boolean valu
Object: object
Function: function
Array: array
Date: date
Regexp: regular
Number syntax
Number includes two kinds of values: integer and decimal.
Var a = 10 setvar PI = 3.141592653589793; attribute
Constructor: returns the string "Number".
Method
ToString
ToLocaleString
ValueOf
ToFixed
ToExponential
ToPrecision
For the specific use of the above methods, please refer to the ES5 standard. String syntax
String can be written in two ways:
'hello world'; "hello world"; attribute
Constructor: returns the string "String".
Length
Please refer to the ES5 standard for the specific meaning of attributes other than constructor. Method
ToString
ValueOf
CharAt
CharCodeAt
Concat
IndexOf
LastIndexOf
LocaleCompare
Match
Replace
Search
Slice
Split
Substring
ToLowerCase
ToLocaleLowerCase
ToUpperCase
ToLocaleUpperCase
Trim
For the specific use of the above methods, please refer to the ES5 standard. Boolean syntax
Boolean values have only two specific values: true and false.
Attribute
Constructor: returns the string "Boolean".
Method
ToString
ValueOf
For the specific use of the above methods, please refer to the ES5 standard. Object syntax
Object is an unordered key-value pair. The usage is as follows:
Var o = {} / generate a new empty object / / generate a new non-empty object o = {'string': 1, / the key of / / object can be the string const_var: 2, the key of / / object can also be the identifier func: {}, the value of / / object can be any type}; / / the read operation of the object property console.log (1 = = o [' string']) Console.log (2 = o.const_var); / / write operation of object attribute o ['string'] + +; o [' string'] + = 10. Read operation of object attribute console.log (12 = = o ['string']); console.log (13 = o.const_var); attribute
Constructor: returns the string "Object".
Console.log ("Object" = = {k: "1", v: "2"} .constructor) method
ToString: returns the string "[object Object]".
Function syntax
Function supports the following definition methods:
/ / method 1function a (x) {return x;} / / method 2var b = function (x) {return x;}
Function also supports the following syntax (anonymous functions, closures, etc.):
Var a = function (x) {return function () {return x;}} var b = a (100); console.log = = b (); arguments
You can use the arguments keyword in function. This keyword currently supports only the following attributes:
Length: the number of arguments passed to the function.
[index]: each parameter passed to the function can be iterated through the index subscript.
Sample code:
Var a = function () {console.log (3 = arguments.length); console.log (100 = arguments [0]); console.log (200 = arguments [1]); console.log (300 = arguments [2]);}; a (100200300); attribute
Constructor: returns the string "Function".
Length: returns the number of formal parameters of the function.
Method
ToString: returns the string "[function Function]".
Sample code:
Var func = function (a function Function bjorc) {} console.log ("Function" = func.constructor); console.log (3 = func.length); console.log ("[function Function]" = func.toString ()); array syntax
Array supports the following definition methods:
Var a = []; / / generate a new empty array a = [1, "2", {}, function () {}]; / / generate a new non-empty array with array elements that can be attributes of any type
Constructor: returns the string "Array".
Length
Please refer to the ES5 standard for the specific meaning of attributes other than constructor. Method
ToString
Concat
Join
Pop
Push
Reverse
Shift
Slice
Sort
Splice
Unshift
IndexOf
LastIndexOf
Every
Some
ForEach
Map
Filter
Reduce
ReduceRight
For the specific use of the above methods, please refer to the ES5 standard. Date syntax
To generate a date object, you need to use the getDate function, which returns an object at the current time.
GetDate () getDate (milliseconds) getDate (datestring) getDate (year, month [, date [, hours [, minutes [, seconds [, milliseconds])
Parameter milliseconds: number of milliseconds calculated from 00:00:00 UTC on January 1, 1970 datestring: date string in the format "month day, year hours:minutes:seconds"
Sample code:
Var date = getDate (); / / returns the current time object date = getDate (1500000000000); / / Fri Jul 14 2017 10:40:00 GMT+0800 (China Standard time) date = getDate ('2017-7-14'); / / Fri Jul 14 2017 00:00:00 GMT+0800 (China Standard time) date = getDate (2017, 6, 14, 10, 40, 0, 0); / Fri Jul 14 10:40:00 GMT+0800 (China Standard time) attribute
Constructor: returns the string "Date".
Method
Parse
UTC
Now
ToString
ToDateString
ToTimeString
ToLocaleString
ToLocaleDateString
ToLocaleTimeString
ValueOf
GetTime
GetFullYear
GetUTCFullYear
GetMonth
GetUTCMonth
GetDate
GetUTCDate
GetDay
GetUTCDay
GetHours
GetUTCHours
GetMinutes
GetUTCMinutes
GetSeconds
GetUTCSeconds
GetMilliseconds
GetUTCMilliseconds
GetTimezoneOffset
SetTime
SetMilliseconds
SetUTCMilliseconds
SetSeconds
SetUTCSeconds
SetMinutes
SetUTCMinutes
SetHours
SetUTCHours
SetDate
SetUTCDate
SetMonth
SetUTCMonth
SetFullYear
SetUTCFullYear
ToUTCString
ToISOString
ToJSON
For the specific use of the above methods, please refer to the ES5 standard. Regexp syntax
The getRegExp function is required to generate the regexp object.
GetRegExp (pattern [, flags])
Parameter: pattern: the contents of the regular expression. Flags: modifier. This field can only contain the following characters: G: globali: ignoreCasem: multiline.
Sample code:
Var a = getRegExp ("x", "img"); console.log ("x" = a.source); console.log (true = a.global); console.log (true = a.ignoreCase); console.log (true = a.multiline); attribute
Constructor: returns the string "RegExp".
Source
Global
IgnoreCase
Multiline
LastIndex
Please refer to the ES5 standard for the specific meaning of attributes other than constructor. Method
Exec
Test
ToString
For the specific use of the above methods, please refer to the ES5 standard. Data type judgment constructor attribute
The constructor attribute can be used to determine the data type.
Sample code:
Var number = 10 true;console.log console.log ("Number" = number.constructor); var string = "str"; console.log ("String" = string.constructor); var boolean = true;console.log ("Boolean" = boolean.constructor); var object = {}; console.log ("Object" = = object.constructor); var func = function () {}; console.log ("Function" = func.constructor); var array = []; console.log ("Array" = array.constructor); var date = getDate () Console.log ("Date" = date.constructor); var regexp = getRegExp (); console.log ("RegExp" = regexp.constructor); typeof
Using typeof, you can also distinguish some data types.
Sample code:
Var number = 10 getRegExp boolean = true;var object = {}; var func = function () {}; var array = []; var date = getDate (); var regexp = getRegExp (); console.log ('number' = typeof number); console.log (' boolean' = typeof boolean); console.log ('object' = typeof object); console.log (' function' = typeof func); console.log ('object' = = typeof array); console.log (' object' = typeof date) Console.log ('object' = typeof regexp); console.log (' undefined' = typeof undefined); console.log ('object' = typeof null); read here, this article "what are the data types of WeChat Mini Programs WXS language" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, please 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.