In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what internal objects in Jscript, I believe most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Internal object
Microsoft Jscript provides 11 internal (or "built-in") objects. They are Array, Boolean, Date, Function, Global, Math, Number, Object, RegExp, Error, and String objects. Each object has related methods and properties, which are described in detail in the language reference. Some objects are also described in this section.
Array object
An array subscript can be thought of as a property of an object, which is referenced by a numerical index. Note that named attributes added to an array cannot be indexed by numbers; they are separated from array elements.
Use the new operator and the Array () constructor to generate a new array, as in the following example.
Var theMonths = new Array (12)
TheMonths [0] = "Jan"
TheMonths [1] = "Feb"
TheMonths [2] = "Mar"
TheMonths [3] = "Apr"
TheMonths [4] = "May"
TheMonths [5] = "Jun"
TheMonths [6] = "Jul"
TheMonths [7] = "Aug"
TheMonths [8] = "Sep"
TheMonths [9] = "Oct"
TheMonths [10] = "Nov"
TheMonths [11] = "Dec"
When you generate an array with the keyword Array, Jscript contains the length attribute, which records the number of entries to the array. If no value is specified for the property, the length is set to 0 and the array has no entry point. If you specify a numeric value, the length is set to that number. If more than one parameter is specified, these parameters are used as entries to the array. In addition, the number of parameters is assigned to the length property. For example, the following example is equivalent to the previous example.
Var theMonths = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun")
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
When you add an element to an array generated with the keyword Array, Jscript automatically changes the value of the attribute length. Array indexes in Jscript always start with 0 instead of 1, so the attribute length is usually 1 larger than the maximum index of the array.
String object
In Jscript, strings (and numbers) can be treated as objects. The string object has some built-in methods that can be used with your own strings. One of them is the substring method, which returns part of the string. This method takes two numbers as parameters.
AString = "0123456789"
Var aChunk = aString.substring (4,7); / / set aChunk to "456".
Var aNotherChunk = aString.substring (7,4); / / set aNotherChunk to "456".
/ / use the above example of generating an array:
FirstLetter = theMonths [5] .substring (0Magne1); / / set the variable firstLetter to "J".
Another property of the String object is the length property. This property contains the number of characters in the string (the empty string is 0). It is a numerical value that can be used directly in the calculation.
Var howLong = "Hello World" .length / / sets the variable howLong to 11.
Math object
The Math object has many predefined properties and methods. Properties are special numbers. One of these special numbers is the pi value (approximately 3.14159... ). This is the Math.PI property, as shown in the following example.
/ / declare a radius variable and assign a value.
Var circleArea = Math.PI * radius * radius; / / Note Math and PI capitalization.
One of the built-in methods of the Math object is the power method (or pow), which is used to obtain the power of a specified number. The following example uses both pi and power.
/ / this formula calculates the volume of a sphere with a given radius.
Volume = (4bat 3) * (Math.PI*Math.pow (radius,3))
Date object
The Date object can be used to represent any date and time, get the current system date, and calculate the interval between the two dates. It has some predefined properties and methods. Typically, the Date object gives the week; month, number of days, and year; and time in hours, minutes, and seconds. This information is based on the number of milliseconds beginning on January 1, 1970 with GMT being Greenwich mean time (the preferred term is UTC, or "Global Standard time", which refers to a signal issued by the World time Standard). Jscript can handle 250000 B.C. To the date in the range of 255000 A.D.
Create a new Date object using the new operator. The following example calculates the number of days that have passed in the current year and the number of days remaining in the year.
/ *
This example uses the previously defined array of month names.
The first statement is in the format "Day Month Date 00:00:00 Year"
Assign a value to the thisIsToday variable.
* /
Var thisIsToday = new Date ()
Var toDay = new Date (); / / get today's date.
/ / extraction year, month, day.
Var thisYear = toDay.getFullYear ()
Var thisMonth = theMonths [toDay.getMonth ()]
Var thisDay = thisMonth + "" + toDay.getDate () + "," + thisYear
Number object
In addition to the special numeric properties available in the Math object, such as PI, the Number object has several other numeric properties in Microsoft Jscript.
Attribute description
The maximum possible number of MAX_VALUE is approximately 1.79Eq308; it can be positive or negative. (the specific values vary slightly from system to system. )
The minimum possible number of MIN_VALUE is about 2.22Emur308; it can be positive or negative. (the specific values vary slightly from system to system. )
NaN special non-quantitative value, "not numeric value".
Any positive value whose POSITIVE_INFINITY is larger than the maximum positive number (Number.MAX_VALUE) is automatically converted to this value, representing positive infinity.
Any value whose NEGATIVE_INFINITY is smaller than the smallest negative number (negative Number.MAX_VALUE) is automatically converted to this value, which represents negative infinity.
Number.NaN is a special property defined as "not a numeric value". For example, divide by 0 and return NaN. An attempt to parse a string that cannot be parsed into a number also returns Number.NaN. The result of comparing NaN with any number or itself is not equal. Instead of testing NaN results by comparing with Number.NaN, you should use the isNaN () function.
The above is all the contents of the article "what are the internal objects in Jscript"? thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.