Method of calling functions in JavaScript

Ethan Bierlein

So, lets say I have a little program that gives the user an alert that says Hello, that is inside of a function. Everyone says that you should call functions like this:

var thefunct = awesomefunct();

Yet it still works perfectly fine like this:

awesomefunct();

What is the difference between the two, and why couldn't I just use the second one? I know that both methods work but all my programmer friends tell me to use the first one. Why?

JohanSellberg

If you run

awesomefunct()

You call the function. So when you type:

var thefunct = awesomefunct();

You run the function and assign the result to thefunct variable.

after that just typing

thefunct

Wont call the function. So there is not that much differencebetween the 2 other than that you catch the return value on the first 1.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a javascript constructor functions method

From Dev

Testable method for calling global javascript functions in angularjs controllers

From Dev

javascript calling nested functions

From Dev

Calling functions and namespacing - JavaScript

From Dev

Calling different JavaScript functions

From Dev

Calling Objects as Functions JavaScript

From Dev

Calling nested javascript functions

From Javascript

Javascript calling prototype functions in constructor

From Dev

Calling JavaScript functions via PHP

From Dev

JavaScript : Calling Recursive Functions With Promises

From Dev

javascript calling multiple functions simultaneously

From Dev

Javascript functions not calling in correct order

From Dev

Pass variables in calling javascript functions?

From Dev

JavaScript helper functions calling eachother

From Dev

Calling parent attribute and functions in javascript?

From Dev

Calling multiple Javascript functions onSubmit

From Dev

Calling JavaScript functions from TypeScript

From Dev

Calling Javascript functions in async timing

From Dev

Calling and Passing Nested Functions in JavaScript

From Dev

Calling functions like properties in JavaScript?

From Dev

calling objects of functions in constructor in javascript

From Javascript

Calling method using JavaScript prototype

From Dev

JavaScript calling a method on an object syntax

From Dev

Javascript calling other object method

From Dev

Calling a method inside another method JavaScript

From Dev

Calling Javascript prototype method from another method

From Java

Calling Javascript functions from a Java Applet

From Dev

Calling functions and getting error that it's not a function in JavaScript

From Dev

Prevent Client from calling JavaScript functions

Related Related

  1. 1

    Calling a javascript constructor functions method

  2. 2

    Testable method for calling global javascript functions in angularjs controllers

  3. 3

    javascript calling nested functions

  4. 4

    Calling functions and namespacing - JavaScript

  5. 5

    Calling different JavaScript functions

  6. 6

    Calling Objects as Functions JavaScript

  7. 7

    Calling nested javascript functions

  8. 8

    Javascript calling prototype functions in constructor

  9. 9

    Calling JavaScript functions via PHP

  10. 10

    JavaScript : Calling Recursive Functions With Promises

  11. 11

    javascript calling multiple functions simultaneously

  12. 12

    Javascript functions not calling in correct order

  13. 13

    Pass variables in calling javascript functions?

  14. 14

    JavaScript helper functions calling eachother

  15. 15

    Calling parent attribute and functions in javascript?

  16. 16

    Calling multiple Javascript functions onSubmit

  17. 17

    Calling JavaScript functions from TypeScript

  18. 18

    Calling Javascript functions in async timing

  19. 19

    Calling and Passing Nested Functions in JavaScript

  20. 20

    Calling functions like properties in JavaScript?

  21. 21

    calling objects of functions in constructor in javascript

  22. 22

    Calling method using JavaScript prototype

  23. 23

    JavaScript calling a method on an object syntax

  24. 24

    Javascript calling other object method

  25. 25

    Calling a method inside another method JavaScript

  26. 26

    Calling Javascript prototype method from another method

  27. 27

    Calling Javascript functions from a Java Applet

  28. 28

    Calling functions and getting error that it's not a function in JavaScript

  29. 29

    Prevent Client from calling JavaScript functions

HotTag

Archive