Define Property In The Object Prototype And Get The Object's Type
I have created a property on the Object's prototype that is an object with some functions: Object.defineProperty(Object.prototype, 'json', { value: function() { re
Solution 1:
What you are looking for is instanceof
operator:
("simple string".json()._value) instanceofString === true
Solution 2:
For not getting the this
value casted to an object, you can use strict mode:
Object.defineProperty(Object.prototype, "json", {
value: function() {
"use strict";
return {
_value: this,
parse: function() {
}
};
}
});
typeof"simple string".json()._value// "string"typeofnewString("simple string").json()._value// "object"
Post a Comment for "Define Property In The Object Prototype And Get The Object's Type"