Difference Between Static and Const in JavaScript Last Updated : 21 Oct, 2021 Comments Improve Suggest changes Like Article Like Report Static variable: A static variable in JavaScript is basically a property of the class which is not used on the object of the class but is used in the class itself. This static variable is stored into the data segment of the memory and its value is shared among all the objects/instances created in that particular class. To declare a variable/function as static we used the 'static' keyword. In the case of a static variable, its value is set at the runtime itself and it is a global value that can be used by the instance of the class. Example: In the following code, we have declared a static method in class z and printed it using the document .write() method. JavaScript <script> class z { static staticMethod() { return "Displaying geeks for " + "geeks using static method."; } } document.write(z.staticMethod()); </script> Output: Constant: A constant variable in JavaScript is a variable that has a constant or a fixed value which remains the same ie. which does not change throughout the program. Any kind of modification in its value is not possible once it is declared. If the programmer tries to modify its value the compiler shows an error, this is because as soon as we have declared a variable as constant it tells the compiler that this is a fixed value and should be prevented from making any changes to it. Example: Below is the implementation of const keyword in JavaScript. In the following code, we have declared a variable as const and using document.write() method, we have displayed its value. JavaScript <script> const value= 8; document.write(value); </script> Output: 8 Difference between Static and Constant: Static ConstantThe static methods are basically utility functions creating or making a copy of an object.The const variable is basically used for declaring a constant value that cannot be modified.A static keyword is been used to declare a variable or a method as static.A const keyword is been used to assign a constant or a fixed value to a variable.In JavaScript, the static keyword is used with methods and classes too.In JavaScript, the const keyword is used with arrays and objects too.The value of a static variable can be modified.The value of the constant variable cannot be modified.Static is a storage specifier.Const/Constant is a type qualifier.Static can be assigned for reference types and set at run time.Constants are set at compile-time itself and assigned for value types only. Comment More infoAdvertise with us Next Article Difference Between Static and Const in JavaScript G gauravgandal Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads Difference between var, let and const keywords in JavaScript JavaScript provides three ways to declare variables: var, let, and const, but they differ in scope, hoisting behaviour, and re-assignment rules. Understanding these differences helps write more predictable and maintainable code.What is var, let and const in JavaScript?var: Declares variables with fu 6 min read Difference between Object.freeze() and const in JavaScript ES6 has brought several new features and methods into JavaScript since its release. Amongst these new features are Object.freeze() method and const. Sometimes people get confused between Object.freeze() method and const but the Object.freeze() and const are completely different. In this article we w 3 min read Difference between var and let in JavaScript In the early days of JavaScript, there was only one way of declaring variables and that was using the var keyword. A variable declared with var is defined throughout the program. One of the issues with using the var keyword was redeclaring a variable inside a block will also redeclare the variable o 3 min read Difference Between Const and Readonly in TypeScript The const and readonly both are used to create the variables and properties that can not be re-assigned once they get initialized by some value. But they are different from each other. Let us discuss the differences between them.ConstThe const keyword is used to declare a constant variable that cann 4 min read Difference Between Variables and Objects in JavaScript The variables and objects are fundamental concepts but they serve different purposes. The Variables are used to store data values while objects are used to group related data and functions into a single entity. JavaScript VariableA variable in JavaScript is a named container that stores a value. It 2 min read Difference between TypeScript and JavaScript Ever wondered about the difference between JavaScript and TypeScript? If you're into web development, knowing these two languages is super important. They might seem alike, but they're actually pretty different and can affect how you code and build stuff online.In this article, we'll break down the 4 min read What's the Difference Between "const" and "val" in Kotlin? In Kotlin, as in other programming languages, properties can be mutable (changeable) or immutable (not changeable). To declare an immutable property, we utilize the terms const and val. Developers are frequently perplexed as to when to utilize one of these phrases. In this article, we will examine t 4 min read What is the difference between â(â¦);â and â{â¦}â in ReactJS ? When you write JavaScript, you can use either the "(â¦)" or "{â¦}" pattern to define objects. In ReactJS, (...); and {...} are used in different contexts and have different purposes, and are used to denote different types of code structures. What is "(â¦);" in React JS ?In ReactJS, (...); is used to de 5 min read Differences Between Undeclared and Undefined Variables in JavaScript In JavaScript, variables are declared using keywords like var, let, or const. The scope and behavior of variables depend on how they are declared:var: Has function scope or global scope. If not declared explicitly, a var variable becomes an undeclared global variable when assigned a value.let and co 4 min read Difference between ES5 and ES6 ECMAScript (ES) is a standardized scripting language specification developed by Ecma International. It serves as the foundation for JavaScript and many other scripting languages. Over time, different versions of ECMAScript have been released, with ES5 (ECMAScript 5) and ES6 (ECMAScript 6) being two 3 min read Like