-
Notifications
You must be signed in to change notification settings - Fork 0
/
l2.1.js
59 lines (53 loc) · 1.17 KB
/
l2.1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Created by Yura on 18.03.2017.
*/
function MyClass() {};
MyClass.prototype.addProp = function(key, value){
Object.defineProperty(this, key,{
value: value,
configurable:true,
enumerable:true,
writable:true
})
};
MyClass.prototype.constProp = function(key, value){
Object.defineProperty(this, key,{
value: value,
configurable:false,
enumerable:true,
writable:false
})
};
MyClass.prototype.hidenProp = function(key){
Object.defineProperty(this, key,{
set:function (value) {
this.key= value
},
get:function () {
return this.value
},
configurable:false,
enumerable:false,
})
};
MyClass.prototype.getPropVal = function () {
var prop = [];
for(var key in this){
if(obj.hasOwnProperty(key)){
prop.push(obj[key])
}
}
return prop;
};
var obj = new MyClass();
obj.addProp("prop",{});
obj.constProp("prop2","Bla-bla-lend");
obj.prop2="dsfdsf";
obj.hidenProp("prop3","Wazzup");
for(var k in obj){
if(obj.hasOwnProperty(k)) {
console.log(k)
}
}
console.log(obj);
console.log(obj.getPropVal());