1. Regular functions
JavaScript regular functions include the following 9 functions:
(1) alert function: displays a warning dialog box, including an OK button.
(2)confirm function: Display a confirmation dialog box, including OK and Cancel buttons.
(3)escape function: Convert characters into Unicode codes.
(4) eval function: calculates the result of an expression.
(5) isNaN function: Test whether (true) or not (false) is not a number.
(6)parseFloat function: Convert a string into dotted digital form.
(7)parseInt function: Convert the string into integer digital form (the decimal system can be specified).
(8)prompt function: Display an input dialog box, prompting to wait for user input. For example:
(9)unescape function: Decode characters encoded by the escape function.
2. Array function
JavaScript array function includes the following 4 functions:
(1) join function: convert and connect all elements in the array into a string. Example:
Program code
Function JoinDemo()
{
var a, b;
a = new Array(0,1,2,3,4);
b = a.join("-");//Separator
return(b);//Returned b=="0-1-2-3-4"
}
(2)langth function: Returns the length of the array. Example:
Program code
function LengthDemo()
{
var a, l;
a = new Array(0,1,2,3,4);
l = a.length;
return(l);//l==5
}
(3)reverse function: Reverse the order of array elements. Example:
Program code
function ReverseDemo()
{
var a, l;
a = new Array(0,1,2,3,4);
l = a.reverse();
return(l);
}
(4) Sort function: Reorder array elements. Example:
Program code
function SortDemo()
{
var a, l;
a = new Array("X","y","d", Z", "v","m","r");
l = a.sort();
return(l);
}
3. Date function
javascript The date function includes the following 20 functions:
(1) getDate function: returns the "day" part of the date, with values from 1 to 31. Example:
Program code
function DateDemo()
{
var d, s = "Today's date is: ";
d = new Date();
s = (d.getMonth() 1) "/";
s = d.getDate() "/";
s = d.getYear();
return(s);
}
(2) getDay function: Returns the day of the week, the value is 0~6, where 0 means Sunday, 1 means Monday,..., 6 means Saturday. Example:
Program code
function DateDemo()
{
var d, day, x, s = "Today is: ";
var x = new Array("Sunday ", "Monday", "Tuesday");
var x = x.concat("Wednesday", "Thursday", "Friday");
var x = x.concat("Saturday");
d = new Date();
day = d.getDay();
return(s = x[day]); hour" part, the value is 0~23. example.
Program code
function TimeDemo()
{
var d, s = "The current local time is: ";
var c = ":";
d = new Date();
s = d.getHours() c;
s = d.getMinutes() c;
s = d.getSeconds() c;
s = d.getMilliseconds ();
Return(s);
See the example above.
(5) getMonth function: Returns the "month" part of the date, with a value of 0 to 11. Among them, 0 represents January, 2 represents March, ..., and 11 represents December. See the previous example
.
(6) getSeconds function: Returns the "seconds" part of the date, the value is 0~59. See previous example.
(7)getTime function: Returns the system time.
Program code
function GetTimeTest()
{
var d, s, t;
var MinMilli = 1000 * 60; 🎜> var DyMilli = HrMilli * 24;
d = new Date();
t = d.getTime();
s = "It's been "
s = Math.round(t / DyMilli) " days since 1/1/70";
return(s);
time difference) in minutes.
Program code
function TZDemo()
{
var d, tz, s = "The current local time is ";
d = new Date();
tz = d.getTimezoneOffset();
if (the name of the link point of tz, the URL address set by another function link.
(2) big function: increase the font to size one, and ...The label result is the same. (3) Blink function: Makes the string blink, which is the same as the ... label result.
(4) Bold function: Makes the font bold, which is the same as the ... label result. .
(5) charAt function: Returns a character specified in the string. (6) Fixed function: Sets the font to a fixed-width font, the same as... tag result. 7) Fontcolor function: Set the font color, which is the same as the label result. (8) Fontsize function: Set the font size, which is the same as the label result. (9) IndexOf function: Return the first one in the string. Find the subscript index, starting from the left.
(10)italics function: Make the font italic, the same as... tag result.
(11)lastIndexOf function: return the first one in the string. Find the subscript index, starting from the right.
(12)length function: Return the length of the string (without parentheses)
(13)Link function: Generate a hyperlink, equivalent to setting.
(14) Small function: Reduce the font size by one size, the same result as... tag.
(15) Strike function: Add a horizontal line in the middle of the text, as... .The label result is the same.
(16) Sub function: Display the string as a subscript (17) Substring function: Return the specified characters in the string. sup function: Display the string as superscript. (19) toLowerCase function: Convert the string to lowercase. (20) ToUpperCase function: Convert the string to uppercase.
//Check whether it is all composed of numbers
Program code
function isDigit(s)
{
var patrn=/^[0-9]{1 ,20}$/;
if (!patrn.exec(s)) return false
return true
}
//Verify login name: only 5 can be entered -20 strings starting with letters and can contain numbers, "_", "."
Program code
function isRegisterUserName(s)
{
var patrn=/^[ a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$/;
if (!patrn.exec(s)) return false
return true
}
//Verify user name: Only 1-30 strings starting with letters can be entered
Program code
function isTrueName( s)
{
var patrn=/^[a-zA-Z]{1,30}$/;
if (!patrn.exec(s)) return false
return true
}
//Verification password: only 6-20 letters, numbers, and underscores can be entered
Program code
function isPasswd(s)
{
var patrn=/^(w){6,20}$/;
if (!patrn.exec(s)) return false
return true
}
/ /Verify ordinary telephone and fax numbers: It can start with " ", and in addition to numbers, it can contain "-"
Program code
function isTel(s)
{
//var patrn =/^[ ]{0,1}(d){1,3}[ ]?([-]?(d){1,12}) $/;
var patrn=/^[ ]{0 ,1}(d){1,3}[ ]?([-]?((d)|[ ]){1,12}) $/;
if (!patrn.exec(s)) return false
return true
}
//Verify mobile phone number: must start with a number. In addition to numbers, it can contain "-"
Program code
function isMobil(s)
{
var patrn=/^[ ]{0,1}(d){1,3}[ ]?([-]?((d)|[ ]){ 1,12}) $/;
if (!patrn.exec(s)) return false
return true
}
//Verify postal code
Program code
function isPostalCode(s)
{
//var patrn=/^[a-zA-Z0-9]{3,12}$/;
var patrn=/^[ a-zA-Z0-9 ]{3,12}$/;
if (!patrn.exec(s)) return false
return true
}
//Verification Search keywords
Program code
function isSearch(s)
{
var patrn=/^[^`~!@#$%^&*() =|\][ ]{}:;',./?]{1}[^`~!@$%^&() =|\][]{}:;',.?]{0, 19}$/;
if (!patrn.exec(s)) return false
return true
}
Program code
function isIP(s) // by zergling
{
var patrn=/^[0-9.]{1,20}$/;
if (!patrn.exec(s)) return false
return true
}

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

10 fun jQuery game plugins to make your website more attractive and enhance user stickiness! While Flash is still the best software for developing casual web games, jQuery can also create surprising effects, and while not comparable to pure action Flash games, in some cases you can also have unexpected fun in your browser. jQuery tic toe game The "Hello world" of game programming now has a jQuery version. Source code jQuery Crazy Word Composition Game This is a fill-in-the-blank game, and it can produce some weird results due to not knowing the context of the word. Source code jQuery mine sweeping game

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

This tutorial demonstrates how to create a captivating parallax background effect using jQuery. We'll build a header banner with layered images that create a stunning visual depth. The updated plugin works with jQuery 1.6.4 and later. Download the

This article demonstrates how to automatically refresh a div's content every 5 seconds using jQuery and AJAX. The example fetches and displays the latest blog posts from an RSS feed, along with the last refresh timestamp. A loading image is optiona

Matter.js is a 2D rigid body physics engine written in JavaScript. This library can help you easily simulate 2D physics in your browser. It provides many features, such as the ability to create rigid bodies and assign physical properties such as mass, area, or density. You can also simulate different types of collisions and forces, such as gravity friction. Matter.js supports all mainstream browsers. Additionally, it is suitable for mobile devices as it detects touches and is responsive. All of these features make it worth your time to learn how to use the engine, as this makes it easy to create a physics-based 2D game or simulation. In this tutorial, I will cover the basics of this library, including its installation and usage, and provide a

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor
