âš ī¸ Warning âš ī¸ Deprecated Code! This video tutorial contains outdated code.
💡 If you wish to update it, any AI assistant will update the code for you in seconds.

Class OOP Tutorial Intro to Object Oriented Programming

Published : November 17, 2014   •   Last Edited : November 24, 2025   •   Author : Adam Khoury
This tutorial is an introduction to creating class based code in JavaScript, also known as OOP(Object Oriented Programming). Because it is a class-less prototype-based language, special syntax is applied to your JavaScript in order to achieve OOP features that we see in languages such as C++, C#, PHP, Java, Perl, Python and more. JavaScript has no class statement for establishing your classes like other popular languages do, but we can still create class based OOP code in JavaScript.
function exampleClass(){
    this.property1 = 5;
    this.property2 = "World";
    this.method1 = function(arg1){
	return arg1+" "+this.property2;
    }
}

var instance1 = new exampleClass();
var instance2 = new exampleClass();

alert(instance1.method1("Hello"));

instance1.property1 = 10;

alert(instance1.property1);
alert(instance2.property1);

Many times an application can run smoothly and complete without a class based style of code, but sometimes your application or work situation will demand it. Large scale multi-author software demands to be class-based for extensibility reasons.