JavaScript Difference between Methods and Functions

Home » JavaScript Difference between Methods and Functions

JavaScript Difference between Methods and Functions

JavaScript Functions: A function is a block of code written to perform some specific set of tasks. We can define a function using the function keyword, followed by Name and optional parameters. The body of a function is enclosed in Curly braces.


function helloName(parameters) {
     // Just Write Hello World In The Console
    console.log("Hello World!");


  • The function is executed when something calls/invokes it.
  • Arguments are values a function receives when it is invoked.
  • Parameters are listed inside round parenthesis after the name of the function.
  • The name of the function may contain letters, digits, dollar signs, underscore.
  • When the control reaches the return statement, JavaScript will stop executing and the value is returned to the caller.

Example: Below is the function to print your name in the console.

function helloWorld(parameters) {
    const name = "Amran";
    console.log(`Hello ${name}!`);


Hello Amran!

JavaScript Methods: A JavaScript method is a property of an object that contains a function definition. Methods are functions stored as object properties. Object method can be accessed with the following syntax:


object = {
    methodName: function() {
        // Some Code...



  • Actions that can be performed on objects are what we term JavaScript methods.
  • The objects can also be called without using parenthesis.
  • This refers to the owner object in a method.

Example: The following example shows the method that is invoked with an object called employee.

const employee = {
  name: "Amran",
  department: "sales",
  details: function() {
    return + " works with Department " + this.department;


Amran works with Department sales

Difference Between Function and Method:

  • A function can be called directly by its name.
  • A function can pass the data that is operated and may return the data. 
  • Data passed to a function is explicit.
  • A function lives on its own.
  • A method consists of a code that can be called by the name of its object and its method name using dot notation or square bracket notation..
  • The method operates the data contained in a Class.
  • A method implicitly passes the object on which it was called.
  • A method is a function associated with an object property

you can find more useful articles on AMK


I’m Front End Developer with more than 2 years of experience, I love to learn every day, and share this knowledge with other developers. if you are reading this now, I wish you have a great day!

28 Comments on JavaScript Difference between Methods and Functions

    October 18, 2021

    Nice and simple... 7 views... I came all the way from dev Community

      Amran Al Kerata
      October 19, 2021

      Thanks bro!🌹

    Moshe Klienblat
    October 19, 2021

    Nice and short

    October 19, 2021

    Useful and short article.

    HopeTech-IT Solution
    November 10, 2021

    Hi, Mahmud Hasan here from HopeTech-IT Solution. We are a professional IT solution service provider based in Bangladesh (South Asia). First of all, I apologize for making such a comment on your website. If you think this comment is not necessary, please delete it. No such comment will be made on your website again.
    Recently your website caught my attention while searching for brand new websites. After entering the website, it seems that your website is brand new or not yet properly configured. That means you may need a professional help. And if that happens then, I think I'm in the right place. As a IT solution service provider, We have dedicated professional team members who can provide all kind of web-related services like Web Design Development (WordPress), Graphics Design, Search Engine Optimization (SEO), Virtual Assistant services at competitive prices.
    You can visit our official website to know the details and price of our services. Feel free to contact us if you are interested in our services. We are always ready to serve you. Hopefully, we will be able to gain your trust and satisfaction.
    Our Official Website:-
    Best Regards,
    Mahmud Hasan
    Marketing Executive
    HopeTech-IT Solution
    Email: [email protected]
    WhatsApp Support: +8801614160365

    January 22, 2022

    canada drugs online [url=]national pharmacies [/url]
    pharmacies shipping to usa pharmacies online
    pharmacies online

    February 5, 2022

    pharmacy online cheap [url=]medical pharmacy [/url]
    canadian online pharmacy canadian pharmacy online
    online drugstore

    February 6, 2022

    cheap prescription drugs [url=]canadian pharmacy cialis 20mg [/url]
    pharmacies online canada pharmaceutical online ordering
    canada pharmaceuticals online generic

    February 6, 2022

    online drugstore pharmacy [url=]best online international pharmacies [/url]
    canadian pharmacy cialis 20mg international pharmacy
    canadian drugstore

    February 6, 2022

    apollo pharmacy online [url=]canadian pharcharmy online [/url]
    mexican pharmacies international pharmacy
    canadian viagra

    February 7, 2022

    canadian pharmacies-247 [url=]canadian drugs [/url]
    navarro pharmacy miami pharmacy online shopping
    canadian drugs pharmacies online

    February 7, 2022

    canadian drugs pharmacy [url=]canadian drugs [/url]
    canadian viagra online medicine to buy
    canadian cialis

    February 8, 2022

    viagra generic online pharmacy [url=]london drugs canada [/url]
    cialis generic pharmacy online canadian drugs online pharmacies
    canadian pharmacy online viagra

    February 9, 2022

    canada pharmaceuticals online generic [url=]canadian pharmacy review [/url]
    pharmacy discount pharmacies online
    canada pharmacy

    February 13, 2022

    walmart pharmacy viagra [url=]national pharmacies [/url]
    canadian pharmacies online canadian prescriptions online
    medical pharmacy

    February 14, 2022

    pills viagra pharmacy 100mg [url=]pharmacie [/url]
    canadian drugs pharmacy canadia online pharmacy
    canadian prescriptions online

    February 14, 2022

    canadian pharcharmy [url=]canadian pharmaceuticals online [/url]
    canadian pharmacy review drugstore online
    canadian pharmacy drugs online

    February 15, 2022

    mexican pharmacies [url=]canadian pharmacy online [/url]
    buy generic viagra online pharmacy in canada
    canada discount drug

    February 16, 2022

    canadian online pharmacies legitimate [url=]canadian pharmacies online [/url]
    canadian online pharmacy pharmacy in canada
    cheap pharmacy online

    February 17, 2022

    online pharmacies [url=]canada pharmacy [/url]
    canadian online pharmacies legitimate online pharmacies canada
    24 hour pharmacy

    February 18, 2022

    pharmacy online prescription [url=]online medicine shopping [/url]
    walmart pharmacy online online order medicine
    compound pharmacy

    February 20, 2022

    tadalafil 20mg

    Kudos. Fantastic stuff.

    February 21, 2022

    canada drugs pharmacy [url=]canadian pharmacy online [/url]
    generic viagra online walmart pharmacy viagra
    national pharmacies

    February 22, 2022

    online pharmacy drugstore [url=]canadian pharcharmy [/url]
    canadian pharmacy king mexican border pharmacies
    pharmacy online cheap

    February 23, 2022

    cialis generic pharmacy online [url=]canadian online pharmacies [/url]
    canadian pharmacies online pharmacy
    national pharmacies

    February 24, 2022

    generic viagra online pharmacy [url=]canadian pharcharmy [/url]
    canada online pharmacies order medicine online
    canadian pharmacy cialis 20mg

    February 24, 2022

    aarp recommended canadian pharmacies [url=]online pharmacy canada [/url]
    national pharmacies online pharmacie
    pharmacy intern

    February 25, 2022

    discount pharmacies [url=]drugstore online [/url]
    canadian pharmacies online medicine shopping
    national pharmacies online

Related Posts:


Best CSS Frameworks in 2021

1. Bootstrap 2. Foundation 3. Bulma 4. Tailwind CSS 5. UI Kit 6. Milligram 7. Materialize CSS Bootstrap Quickly design and customize responsive mobile-first sites


Music Player With Vanilla JavaScript

In this blog tutorial, we are going to set up and build a music player with vanilla JavaScript from scratch ‘without audio tag’, you can


Append and AppendChild in JavaScript

The append and appendchild Methods are too popular and used to add elements into the Document Object Model(DOM). But there is a main difference between