google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank
Guest, register






Popular Built-in JavaScript Functions In this free HTMl JavaScript tutorial, I'll list all of the built-in JavaScript functions available to you. While not everything will be covered, I will cover functions in JavaScript that are 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 JavaScript functions: JavaScript Array Functions, JavaScript Array Properties and Functions, JavaScript Date Functions, JavaScript Math Functions, JavaScript String Functions, JavaScript Document Functions, JavaScript Event Handlers and JavaScript Node Functions.

Why don't you read more JavaScript funtions below for better understand:

- Functions of JavaScript
-


Free iPage Web Hosting for First Year NOW



If you're still looking for a reliable web host provider with affordable rates, why you don't take a little of time to try iPage, only with $1.89/month, included $500+ Free Extra Credits for the payment of 24 months ($45)?

Over 1,000,000+ existisng customers can not be wrong, definitely you're not, too! More important, when you register the web hosting at iPage through our link, we're going to be happy for resending a full refund to you. That's awesome! You should try iPage web hosting for FREE now! And contact us for anything you need to know about iPage.
Try iPage for FREE First Year NOW

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 by day


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web