
- 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
Static Properties in JavaScript
Static properties are assigned to the class function itself and not to its prototype property. These properties can be called directly without instantiating any objects.
Following is the code for static properties in JavaScript −
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 20px; font-weight: 500; color: blueviolet; } </style> </head> <body> <h1>Static Properties in JavaScript</h1> <div class="result"></div> <button class="Btn">CLICK HERE</button> <h3>Click on the above button to the access the static property school of Student</h3> <script> let resEle = document.querySelector(".result"); function Student(name, age) { this.name = name; this.age = age; } Student.school = "St Marks Public School"; document.querySelector(".Btn").addEventListener("click", () => { resEle.innerHTML = "Student.school = " + Student.school; }); </script> </body> </html>
Output
On clicking the ‘CLICK HERE’ button −
- Related Articles
- PHP Static Properties and Methods
- Static methods in JavaScript classes?
- Shared properties in JavaScript
- JavaScript Object Properties
- How to use Static Variables in JavaScript?
- Difference Between Static and Const in JavaScript
- How to create object properties in JavaScript?
- How to delete object properties in JavaScript?
- Window innerWidth and innerHeight Properties in JavaScript.
- How to override derived properties in JavaScript?
- Extract properties from an object in JavaScript
- Implement Private properties using closures in JavaScript
- Merge and group object properties in JavaScript
- How to access JavaScript properties?
- Range Overflow and Range Underflow properties in JavaScript.

Advertisements