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
}

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

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

Dreamweaver Mac version
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
