TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript Object defineProperties() Method

JavaScript Object defineProperties() Method with example on javascript, object, javascript assign(), create(), defineProperties(), defineProperty(), entries(), freeze(), javascript tutorial, javascript array etc.

<< Back to JAVASCRIPT

JavaScript Object.defineProperties() Method

The Object.defineProperties() method defines new or modifies existing properties directly on an object, and returning the object.

Syntax:

Object.defineProperties(obj, props)

Parameter

Obj: The object on which to define or modify properties.

Props: An object whose own enumerable properties constitute descriptors for the properties to be defined or modified.

Return:

This method reruns an object that was passed to the function.

Browser Support:

Chrome Yes
Edge Yes
Firefox 1.5
Opera Yes

Example 1

const object1 = {};
Object.defineProperties(object1, {
  property1:{
value: 44, }
 });
console.log(object1.property1);

Output:

44

Example 2

const object1 = {};
Object.defineProperties(object1, {
  property1: {
    value: 142,
    value: 422,
    value: 423,
    },
 property2: {}
});
console.log(object1.property1);

Output:

423

Example 3

const obj = {};
Object.defineProperties(obj, {
  property1: {
    value: 142,
    value: 422,
    value: 423,
    },
  property2: {
  value: 22,
  value: 12,}
});
console.log(obj.property1,obj.property2);

Output:

423 
12

Next TopicJavaScript Objects




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf