- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 a method and a function?
Method and a function are the same, with different terms. A method is a procedure or function in object-oriented programming.
A function is a group of reusable code which can be called anywhere in your program. This eliminates the need for writing the same code again and again. It helps programmers in writing modular codes.
The following is the syntax of a JavaScript function:
<script type="text/javascript"> <!-- function functionname(parameter-list) { statements } //--> </script>
Here’s an example:
<script type="text/javascript"> <!-- function sayHello() { alert("Hello there"); } //--> </script>
Advertisements