Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript | Object.defineProperties() Method

  • Last Updated : 13 Sep, 2021

The Object.defineProperties() method in JavaScript is Standard built-in Object that is defines a new or modifies existing properties directly on an object and it returns the object.

Object.defineProperties(obj, props) 


  • Obj: This parameter holds the object on which the properties are going to be define or modify.
  • Props: This parameter is an object whose own enumerable properties constitute descriptors for the properties to be defined or modified.

Return Value: This method returns an object which is passed as an argument to the function.
Below examples illustrate the Object.defineProperties() method in JavaScript:
Example 1: 


const geek = {};
Object.defineProperties(geek, {
  prop1: {
    value: "geeksforgeeks",
    writable: true
  prop2: {}



Example 2: 


var geek = {};
Object.defineProperties(geek, {
  'prop1': {
    value: "Geeks",
    writable: true
  'prop2': {
    value: 'Hello',
    writable: false
const geek1 = {}; 
Object.defineProperties(geek1, {
  prop1: { 
    value: "Hi"
    value: "Hello"
    value: "Namaste",
  prop2: { 
    value: " And ", },
    prop3: { 
    value: "learn"
   value: "Stay Safe", } 
console.log(geek1.prop1, geek1.prop2, geek1.prop3);


"Namaste" " And " "Stay Safe"

Supported Browsers: The browsers supported by Object.defineProperties() method are listed below: 

  • Google Chrome 6.0 and above
  • Internet Explorer 9.0 and above
  • Mozilla 4.0 and above
  • Opera 11.1 and above
  • Safari 5.0 and above

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!