H3XED

JavaScript Static Properties and Methods

Sep 28, 2016   Programming   Nick Vogt   Comments
Please note that this post is over a year old and may contain outdated information.
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 (0)

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