Home> Common Problem> body text

What methods do built-in objects have?

小老鼠
Release: 2023-11-07 17:59:36
Original
842 people have browsed it

Built-in object methods include common methods of Array objects, common methods of String objects, common methods of Math objects, common methods of Date objects, etc. Detailed introduction: 1. Common methods of Array objects include push(), pop(), shift(), unshift(), concat(), slice(), splice(), etc.; 2. Common methods of String objects include length, charAt(), concat(), concat(), etc.

What methods do built-in objects have?

Operating system for this tutorial: Windows 10 system, Dell G3 computer.

Different built-in objects have different methods. The following are some common examples of built-in objects and their methods:

1. Common methods of Array objects:

push() : Add one or more elements to the end of the array.

pop(): Remove and return the last element of the array.

shift(): Delete and return the first element of the array.

unshift(): Add one or more elements to the beginning of the array.

concat(): Concatenate two or more arrays.

slice(): Returns a part of the array.

splice(): Add or remove elements from an array.

2. Common methods of String objects:

length: Returns the length of the string.

charAt(): Returns the character at the specified index position.

concat(): Concatenate two or more strings.

indexOf(): Returns the first matching position of the specified character or substring.

substring(): Returns a part of the string.

toUpperCase(): Convert the string to uppercase.

toLowerCase(): Convert the string to lowercase.

3. Commonly used methods of Math objects:

abs(): Returns the absolute value of the number.

ceil(): Round up.

floor(): Round down.

round(): Rounding.

max(): Returns the maximum value in a set of numbers.

min(): Returns the minimum value in a set of numbers.

random(): Returns a random number between 0 and 1.

4. Common methods of Date objects:

getDate(): Returns a certain day in the month.

getMonth(): Returns the month (0-11).

getFullYear(): Returns the year.

getHours(): Returns the number of hours (0-23).

getMinutes(): Returns the number of minutes (0-59).

getSeconds(): Returns the number of seconds (0-59).

getTime(): Returns the number of milliseconds since January 1, 1970.

These are just some examples of methods of common built-in objects. Different built-in objects may have more methods. The specific method also needs to be determined according to the programming language and built-in objects used. You can consult relevant documentation or reference books to learn more about built-in object methods.

The above is the detailed content of What methods do built-in objects have?. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!