
- 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 use of ()(parenthesis) brackets in accessing a function in JavaScript?
The ()(parenthesis) brackets play an important role in accessing a function. Accessing a function without () will return the function definition instead of the function result. If the function is accessed with () then the result can be obtained.
Without ()
Example
In the following example, the function is accessed without () so the function definition is returned instead of the result as shown in the output.
<html> <body> <script> function toCelsius(f) { return (5/9) * (f-32); } document.write(toCelsius); </script> </body> </html>
Output
function toCelsius(f) { return (5/9) * (f-32); }
With ()
Example
In the following example, the function is accessed with () so instead of the function definition, the result is displayed as shown in the output.
<html> <body> <script> function toCelsius(f) { return (5/9) * (f-32); } document.write(toCelsius(208)); </script> </body> </html>
Output
97.77777777777779
- Related Articles
- What is the use of Math.hypot() function in JavaScript?
- What is the use of apply() function in JavaScript?
- What is the use of Math.imul( ) Function in JavaScript?
- What is the use of return statement inside a function in JavaScript?
- Accessing an array returned by a function in JavaScript
- What is the use of JavaScript eval function?
- Why are parenthesis used to wrap a JavaScript function call?
- Accessing variables in a constructor function using a prototype method with JavaScript?
- Finding the balance of brackets in JavaScript
- All ways of balancing n parenthesis in JavaScript
- Finding score of brackets in JavaScript
- Validating brackets in a string in JavaScript
- What is the use of FIND_IN_SET () function in MySQL?
- What is the use of LOCATE() function in MySQL?
- What is the use of pheatmap function in R?

Advertisements