
- 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
In JavaScript, what is meant by 'a function expression is always a constant value'?
If the const is used in a program, and if you try to reassign the value to const variable then an error will arise.
Let’s say the following is our const variable −
const result = (first, second) => first * second;
Now, we will try to reassign a value to the const variable and an erro can be seen in the output.
Example
Following is the code −
const result = (first, second) => first * second; result = first => first =first*10; console.log(result(10,20));
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo284.js.
Output
This will produce the following output on console −
Error is visible “Assignment to constant variable” −
PS C:\Users\Amit\javascript-code> node demo284.js C:\Users\Amit\javascript-code\demo284.js:2 result = first => first =first*10; ^ TypeError: Assignment to constant variable. at Object.<anonymous> (C:\Users\Amit\javascript-code\demo284.js:2:8) at Module._compile (internal/modules/cjs/loader.js:1133:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47
On commenting the below line, you will get the correct result −
// result = first => first =first*10;
Output
This will produce the following output on console −
PS C:\Users\Amit\javascript-code> node demo284.js 200
- Related Articles
- What is meant by Algebraic expression?
- What is meant by a Diatom?
- What is meant by a substance?
- What is meant by a rocket propellant?
- What is meant by a Share Split?
- (a) What is solar constant? What is the value of solar constant?(b) If the energy received by 5 m2 area in 10 minutes is 4200 kJ, calculate the value of solar constant.
- What is meant by a multithreaded program in Java?
- What is meant by a 360-degree selfie?
- What is meant by a pure-equity firm?
- What is meant by Present Value of Growth Opportunities (PVGO)?
- What is Number.NEGATIVE_INFINITY constant in JavaScript?
- What is meant by Compounding?
- What is meant by correlation?
- What is meant by Force?
- What is meant by hypotenuse?

Advertisements