TheDeveloperBlog.com

Home | Contact Us

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

JavaScript Reflect set() Method

JavaScript Reflect set() Method with examples on javascript reflect methods, apply() construct(), defineProperty() method, deleteProperty(), get(), getOwnPropertyDescriptor(), getPrototypeOf(), has(), isExtensible(), ownKeys(), setPrototypeOf() etc.

<< Back to JAVASCRIPT

JavaScript Reflect.set() method

The static Reflect.set() method is used to set the value of an object's property. It returns true if the property was successfully set. Otherwise, it returns false.

Syntax:

Reflect.set(obj, Key, value[, receiver])

Parameters:

Obj: It is the target object on which to set the property.

Key: It is the name of the property to set.

value: It is the value to set.

Receiver: It is the value of this provided for the call to target if a setter is encountered.

Return value:

This method returns a Boolean which indicates whether or not setting the property was successful.

Exceptions:

A TypeError, if the target is not an Object.

Browser Support:

Chrome 49
Edge 12
Firefox 42
Opera 36

Example 1

const array1 = [];
Reflect.set(array1, 2, 'gosse');
console.log(array1[2]);

Output:

"gosse"

Example 2

const obj = {};
Reflect.set(obj, 'pro', 32);
console.log(obj.pro);

Output:

32

Example 3

const n={};
const m={};
Reflect.set(n,'ptou',7);
console.log(n.ptou);
Reflect.set(m,'too',4);
console.log(m.too);

Output:

7
4
Next TopicJavaScript Reflect




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