google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Các hàm JavaScript dựng sẵn phổ biến Bài viết hướng dẫn sử dụng JavaScript này cung cấp danh sách các hàm được xây dựng sẵn của ngôn ngữ lập trình JavaScript. Các hàm được liệt kê trong bài viết này là những hàm JavaScript thường được sử dụng nhất cùng với mô tả ngắn gọn công dụng của chúng.


Nhãn: hàm JavaScript dựng sẵn, hàm JavaScript, danh sách hàm, mô tả ngắn gọn, công dụng

Miễn phí web hosting 1 năm đầu tại iPage



Nếu bạn vẫn còn đang tìm kiếm một nhà cung cấp hosting đáng tin cậy, tại sao không dành chút thời gian để thử với iPage, chỉ với không quá 40.000 VNĐ/tháng, nhưng bạn sẽ được khuyến mãi kèm với quà tặng trị giá trên 10.000.0000 VNĐ nếu thanh toán cho 24 tháng ~ 900.000 VNĐ?

Có trên 1 triệu khách hàng hiện tại của iPage đã & đang hài lòng với dịch vụ, tuyệt đối chắc chắn bạn cũng sẽ hài lòng giống họ! Quan trọng hơn, khi đăng ký sử dụng web hosting tại iPage thông qua sự giới thiệu của chúng tôi, bạn sẽ được hoàn trả lại toàn bộ số tiền bạn đã sử dụng để mua web hosting tại iPage. Wow, thật tuyệt vời! Bạn không phải tốn bất kì chi phí nào mà vẫn có thể sử dụng miễn phí web hosting chất lượng cao tại iPage trong 12 tháng đầu tiên. Chỉ cần nói chúng tôi biết tài khoản của bạn sau khi đăng ký.

Nếu muốn tìm hiểu thêm về ưu / nhược điểm của iPage, bạn hãy đọc đánh giá của ChọnHostViệt.com nhé!
Thử iPage miễn phí cho năm đầu tiên NGAY

In this article, I'll list all of the built in functions available to you with Javascript. While not everything will be covered, I will cover every function that is used on a regular basis. I'm still deciding whether I'll cover Javascript Graphics or AJAX next. Leave comments below to help me understand. On to the functions.

Javascript Array Functions

In previous articles I described how to create Arrays, but if you forgot here is how you create arrays:

  • var a = new array() // Creates an empty array
  • var b = new array(8) // Creates an array with 8 element cells
  • var c = [1, 2, "turtle", "number", true]; // Creates an array with a bunch of random values

Javascript Array Properties and Functions

  • b.length // A property that would return the value of 8, because of the array declaration above
  • c.concat(3,4) // The array c now has the values 1, 2,  "turtle", "number", true, 3, 4
  • c.join(": ") // Returns a string with each element separated by a colon and a space. 1: 2: number: true
  • c.slice(0, 2) // Returns an array which contains all elements between the first value you pass to the second value. In this example you would be returned [1, 2, number]
  • c.sort() // Returns the array elements in alphabetical order. This example returns [1, 2, number, true, turtle]
  • c.toString() // Converts the array into a string and then returns the string.

Javascript Date Functions

There are numerous date functions. I'll cover the most commonly used here.

  • a = new Date(); // Creates a new date object and assigns the current time to it
  • document.write(a.getTime()); : Returns a millisecond representation of a date. ex. 1270487133410
  • document.write(a.getDay()); : Returns the day of the week
  • document.write(a.getFullYear()); : Returns the year of the date
  • document.write(a.getHours()); : Returns the hours of the set date
  • document.write(a.getMinutes()); : Returns the minutes of the set date
  • a.setTime(); : Creates a millisecond representation of a date. ex. 1270487133410
  • a.setDay(); : Sets the day of the week
  • a.setFullYear(); : Sets the year of the date
  • a.setHours(); : Sets the hours of the set date
  • a.setMinutes(); : Sets the minutes of the set date

Javascript Math Functions

Here are a few of the most commonly used Javascript Math Functions

  • isNaN(variableToTest) : Returns true if the variable is a number and false otherwise
  • Math.abs(variableToTest) : Performs an absolute value calculation
  • Math.ceil(variableToTest) : Rounds a number up
  • Math.floor(variableToTest) : Rounds a number down
  • Math.max(x, y) : Returns the larger of the two variables it is passed
  • Math.min(x, y) : Returns the smaller of the two variables it is passed
  • Math.random(): Returns a random number
  • parseFloat(string) : Converts a string into a float number
  • parseInt(string) : Converts a string into an int number

Javascript String Functions

Here are a few of the most used string functions.

  • stringVariable.length : Returns the number of characters in a string
  • stringVariable.charAt(x) : Returns the character at the position sent to this function
  • stringVariable.concat(x1, x2) : Adds one or more values to the end of the string
  • stringVariable.indexOf(wordYourLookingFor, whereToStartSearch) : Searches the string for a chosen word or character
  • stringVariable.match(regexp) : Look for a specific regular expression in a string. See my Javascript Regular Expression tutorial if you don't know what they are.
  • stringVariable.replace(regexp, replacementText) : Search for a regular expression match and then replace the match with the replacement text given
  • stringVariable.slice(startPoint, endPoint) : Extracts a string from the beginning point to the ending point given
  • stringVariable.split(delimiter, maxLength) : Breaks a string into a series of cells, by separating the words by the chosen delimiter. ex. "1,2,3,4″.split(",") would return ["1","2","3","4"]. You have the option of defining a maximum number of elements in the array that is created.

Javascript Document Functions

  • document.getElementsByName(idName) : Provides you with access to a node on the web page by passing it the id Name.
  • document.write() : Appends text or variable values to the web page
  • document.writeln() : Appends text or variable values to the web page, followed by a newline

Javascript Event Handlers

  • onclick : Performs an action when the user clicks on a node in a document
  • ondblclick : Performs an action when the user double clicks on a node in a document
  • onkeydown : Performs an action when the user presses a key
  • onkeypress : Performs an action when the user presses and releases a key
  • onkeyup : Performs an action when the user releases a key
  • onmousedown : Performs an action when the user presses the mouse button
  • onmousemove : Performs an action when the user moves the mouse
  • onmouseout : Performs an action when the user moves the mouse off of an element
  • onmouseover : Performs an action when the user moves their mouse over an element
  • onmouseup : Performs an action when the user releases a mouse button

Javascript Node Functions

  • node.appendChild(nodeName) : Inserts a new node after the node specified.
  • node.insertBefore(nodeName) : Insert a new node in front of the node you specified.
  • node.removeChild(nodeName) : Remove the child node of the node you specified
  • node.replaceChild(nodeName) : Replace a child node with the new one you are specifying

That is basically all of the commonly used prebuilt functions available to you in Javascript. You also basically also know just about all there is to know about Javascript as well. I'm going to cover AJAX, which allows you to communicate with the web server without reloading the web page. Also, look forward to a Javascript Graphics Tutorial.

As always, leave your questions or comments below.

Till next time...

iPhoneKer.com
Save up to 630$ when buy new iPhone 15

GateIO.gomymobi.com
Free Airdrops to Claim, Share Up to $150,000 per Project

https://tooly.win
Open tool hub for free to use by any one for every one with hundreds of tools

chatGPTaz.com, chatGPT4.win, chatGPT2.fun, re-chatGPT.com
Talk to ChatGPT by your mother language

Dall-E-OpenAI.com
Generate creative images automatically with AI

AIVideo-App.com
Render creative video automatically with AI

JavaScript theo ngày


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web