Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between custom and built-in functions in JavaScript?
The custom functions in JavaScript are user-defined functions. JavaScript allows us to write our own functions. The following is the syntax −
Syntax
<script>
<!--
function functionname(parameter-list)
{
statements
}
//-->
</script>
Bult-in functions are functions already provided by JavaScript library, for example, the following are string functions −
| S. No |
Method & Description |
|---|---|
| 1 |
charAt() Returns the character at the specified index. |
| 2 |
charCodeAt() Returns a number indicating the Unicode value of the character at the given index. |
| 3 |
concat() Combines the text of two strings and returns a new string. |
| 4 |
indexOf() Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found. |
Example
The following is an example of a built-in function in JavaScript to concatenate strings −
<html>
<head>
<title>JavaScript String concat() Method</title>
</head>
<body>
<script>
var str1 = new String( "This is string one" );
var str2 = new String( "This is string two" );
var str3 = str1.concat( str2 );
document.write("Concatenated String :" + str3);
</script>
</body>
</html>
Output

Advertisements