Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7535680
test_define_property_simple.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
718 B
Referenced Files
None
Subscribers
None
test_define_property_simple.js
View Options
// Simple test matching MDN example
const
object
=
{};
Object
.
defineProperty
(
object
,
"foo"
,
{
value
:
42
,
writable
:
false
,
});
console
.
log
(
"object.foo:"
,
object
.
foo
);
// Expected output: 42
// Test modifying existing property
const
obj2
=
{
bar
:
10
};
console
.
log
(
"Before defineProperty, obj2.bar:"
,
obj2
.
bar
);
Object
.
defineProperty
(
obj2
,
"bar"
,
{
value
:
20
});
console
.
log
(
"After defineProperty, obj2.bar:"
,
obj2
.
bar
);
// Expected output: 20
// Test return value
const
obj3
=
{};
const
result
=
Object
.
defineProperty
(
obj3
,
"test"
,
{
value
:
123
});
console
.
log
(
"Returned object is same as input:"
,
result
===
obj3
);
// Expected output: true
console
.
log
(
"obj3.test:"
,
obj3
.
test
);
// Expected output: 123
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jun 17, 12:08 PM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
523588
Default Alt Text
test_define_property_simple.js (718 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment