defineproperty Questions
2
Solved
Fiddle
var Assertion = function() {
return { "dummy": "data" };
}
Object.defineProperty(Object.prototype, 'should', {
set: function(){},
get: function(){
return new Assertion(this);
}
});
...
Undersexed asked 21/8, 2011 at 21:11
6
Solved
I would like (mainly for academic reasons) to be able to set an accessor on an array's length using Object.defineProperty(), so than I can notify for size changes.
I am aware of ES6 object observ...
Chronicles asked 5/9, 2013 at 14:31
2
Solved
I'm trying to define an object and create an accessor property for it.
HTML:
<input type='hidden' id='crudMode' value='Create' />
JavaScript:
crudMode = {
create: "Create",
read: "Read...
Downing asked 3/8, 2011 at 9:23
4
Solved
I have some code which defines a getter (but no setter, if such is relevant) on a prototype. The value returned is correct in 99.99% of the cases; however, the goal is to set the property to evalua...
Hyksos asked 10/10, 2014 at 9:46
4
Solved
JavaScript getters and setters can be overridden for specific properties using Object.defineProperty. Is there some way to access the default getter/setter (i.e. the function used if the getter/set...
Wellbeing asked 25/11, 2014 at 15:30
1
Solved
Let's say I have a class which stores the properties of its instances in a nested object:
this.Properties = {
"Position":{
"X": 400,
"Y": 100
},
"Colour"...
Bobbybobbye asked 24/8, 2020 at 17:17
10
Solved
I looked around for how to use the Object.defineProperty method, but couldn't find anything decent.
Someone gave me this snippet of code:
Object.defineProperty(player, "health", {
get: function ...
Yiyid asked 30/8, 2013 at 3:57
7
Solved
My objective is to observe an input value and trigger a handler when its value gets changed programmatically. I only need it for modern browsers.
I have tried many combinations using definePropert...
Bookmark asked 11/10, 2013 at 19:37
3
Solved
In JavaScript (ES5+), I'm trying to achieve the following scenario:
An object (of which there will be many separate instances) each with a read-only property .size that can be read from the outsi...
Cymograph asked 23/5, 2014 at 1:36
2
Solved
Is there anyhow anyway to add some static method to types like Date, String, Array, etc?
For example I want to add method today to Date class and in JavaScript I can simply add a property to it or...
Cq asked 10/10, 2017 at 10:43
3
Solved
How do I get TypeScript to emit property definitions such as:
Object.defineProperties(this, {
view: {
value: view,
enumerable: false,
writable: false,
configurable: false
},
});
Carnation asked 2/10, 2012 at 18:40
1
Solved
I've seen two different techniques of implementing non-native features in javascript,
First is:
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
enumer...
Mourant asked 15/8, 2016 at 19:8
1
Solved
I'm getting an error on Maximum call stack size for this code.
function ValueObject() {
}
ValueObject.prototype.authentication;
Object.defineProperty(ValueObject.prototype, "authentication", {
...
Indian asked 7/7, 2016 at 22:11
3
Solved
Is it possible to have multiple parameters for Object.defineProperty setter function?
E.G.
var Obj = function() {
var obj = {};
var _joe = 17;
Object.defineProperty(obj, "joe", {
get: functi...
Screed asked 10/9, 2013 at 19:22
1
Solved
Let's take the following code:
var obj = {};
var x = Symbol();
Object.defineProperties(obj, {
[x]: {
value: true,
writable: true
},
"property2": {
value: "Hello",
writable: false
}
// etc...
Zumwalt asked 20/3, 2016 at 8:16
1
Solved
Just today I tried to include an older library of mine that uses the Object.defineProperty() method in javascript into an HTML document. I am quite certain that in previous versions of FireFox it w...
Broadminded asked 11/4, 2013 at 15:32
1
Solved
I tried to define some property for String.Prototype in TypeScript:
Object.defineProperty(String.prototype, 'test', {
value: () => {
console.log("this is a test over text " + this);
}
})
i...
Bradford asked 18/10, 2015 at 11:37
1
Can somebody give me a good use case of when to use Object.defineProperty(), Object.prototype.property and Object.property.
Carlita asked 4/8, 2015 at 18:49
1
Solved
Considering the basic scenario of usage, do
foo.bar = 'baz';
and
Object.defineProperty(foo, 'bar', {
value: 'baz',
configurable: true,
enumerable: true,
writable: true
});
behave exactly ...
Peristyle asked 25/4, 2015 at 5:10
2
Solved
How do I remove the property p from the object's prototype?
var Test = function() {};
Object.defineProperty(Test.prototype, 'p', {
get: function () { return 5; }
});
Object.defineProperty(Test.p...
Coronograph asked 29/1, 2015 at 15:29
6
Solved
As you know we can define getters and setters in JS using defineProperty(). I've been stuck when trying to extend my class using defineProperty().
Here is an example code:
I have an array of fiel...
Dimer asked 27/12, 2012 at 0:3
3
I have downloaded the sample 'Breeze 0.83.5' applications from http://www.breezejs.com/documentation/download
The Angular 'ToDo' sample does not work with IE8.
I have included the following scrip...
Ascribe asked 9/1, 2013 at 15:2
2
On the MDN strict mode reference page it says
Any assignment that silently fails in normal code (assignment to a non-writable property, assignment to a getter-only property, assignment to a new ...
Lilybel asked 9/10, 2014 at 22:27
1
Solved
Consider the following code:
var x = 0;
var o = {};
function getter() {
return x;
}
Object.defineProperty(o, "y", {
get: getter,
set: function (y) {
x = y;
Object.defineProperty(o, "y", {...
Sievers asked 3/10, 2014 at 5:13
1
Solved
Does anyone know what version of JavaScript is used by HTA files.
Currently creating some script files - and trying to make use of Object.defineProperty
When running as an HTA - it errors stating...
Tris asked 24/10, 2013 at 13:48
1 Next >
© 2022 - 2024 — McMap. All rights reserved.