
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What is the difference between functions and methods in JavaScript?
Functions and methods are the same in JavaScript, but a method is a function, which is a property of an object.
The following is an example of a function in JavaScript −
function functionname(param1, param2){ // code }
Example
The method is a function associated with an object. The following is an example of a method in JavaScript −
<html> <head> <script> var employee = { empname: "David", department : "Finance", id : 002, details : function() { return this.empname + " with Department " + this.department; } }; document.write(employee.details()); </script> </head> </html>
Output
- Related Articles
- Explain the difference between functions and Methods in Swift
- What is the difference between anonymous and inline functions in JavaScript?
- What is the difference between closure and nested functions in JavaScript?
- What is the difference between Math.ceil() and Math.round() methods in JavaScript?
- What is difference between unescape() and escape() functions in JavaScript?
- What is the difference between custom and built-in functions in JavaScript?
- What is the difference between default and rest parameters in JavaScript functions?
- Difference between regular functions and arrow functions in JavaScript
- What is the difference between non-static methods and abstract methods in Java?
- What is the difference between CONCAT() and CONCAT_WS() functions?
- What is the difference between scipy.cluster.vq.kmeans() and scipy.cluster.vq.kmeans2() methods?
- Difference between shift() and pop() methods in Javascript
- Difference between push() and unshift() methods in javascript
- Difference between test () and exec () methods in Javascript
- What is the difference between jQuery.map() and jQuery.grep() Functions in jQuery?

Advertisements