H3XED
Programming   Browse Topics

JavaScript Static Properties and Methods

Posted Sep 28, 2016 by Nick Vogt
Here is a very simple example on using static properties and methods (variables and functions) with JavaScript.

// Create your class
function TestClass() {}

// A static property
TestClass.staticProperty = "Testing";

// A static method
TestClass.staticMethod = function() {
    console.log(TestClass.staticProperty);
};

// Test it
TestClass.staticMethod();
Share This Post
Facebook Twitter

Comments


Share This Post
Facebook Twitter
H3XED © Nick Vogt   RSS   Privacy Policy   Facebook   Twitter   Google+