I am learning prototype in JavaScript and this is the code I am trying -
<script>
function employee(name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
var trialcoder = new employee('trialcoder', 26, 'M');
//employee.prototype.salary = null;
trialcoder.salary = 19000;
document.write("salary is "+ trialcoder.salary);
</script>
My thoughts- To add another property we need to use prototype
like - employee.prototype.salary = null;
so on un commenting this line, I was expecting an error but it was not..let me know where I am wrong in the prototype
concept.
Code Source - http://www.w3schools.com/jsref/jsref_prototype_math.asp