create getter and setter javascript code example
Example 1: setter&getter java
public class Vehicle {
private String color;
public String getColor() {
return color;
}
public void setColor(String c) {
this.color = c;
}
}
Example 2: getter and setters in js
var person={firstname:"chetha",secondname="kumar",get fullname()
{
return this.firstname+" "+this.secondname;
}
document.write(person.fullname);
var person={firstname:"chethan",secondname="kumar",course:"",set course(x)
{
this.course=x;
}
person.course="bca";
document.write(person.course);