Hi,
OOP is not just limited to PHP, you can implement its concepts to some extent in javascript as well. But before I move on with it in details, the most important thing you need to understand about OOP as fas as Javascript is concerned is the fact, that there are no classes as such, as we have conventionally known. Here the functions are treated as class, which may contain member functions and data members.
OOP is not just limited to PHP, you can implement its concepts to some extent in javascript as well. But before I move on with it in details, the most important thing you need to understand about OOP as fas as Javascript is concerned is the fact, that there are no classes as such, as we have conventionally known. Here the functions are treated as class, which may contain member functions and data members.
Here is the javascript
<script type="text/javascript">
function Person(name)
{
this.name = name;
this.getName = getName;
this.setName = setName;
}
function getName()
{
return this.name;
}
function setName(name)
{
this.name = name;
}
var personObj = new Person('Bob');