Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript Read Only View of an Object

let student = {
    name: 'Jack',
    age: 23
}

const handler = {
    set: function (obj, prop, value) {
        if (obj[prop]) {
            
            // cannot change the student value
            console.log('Read only')
        }
    }
};

const proxy = new Proxy(student, handler);

proxy.name = 'John'; // Read only
proxy.age = 33; // Read only
Comment

PREVIOUS NEXT
Code Example
Javascript :: fetch second parameters 
Javascript :: js tilda 
Javascript :: javascript Undeclared variable is not allowed 
Javascript :: javascript Using yield to Pause Execution 
Javascript :: how to locate an object with a spcific key in js array 
Javascript :: javascript function invocation 
Javascript :: npx cypress --spec run selected tests 
Javascript :: return object from array by property value 
Javascript :: json syntax 
Javascript :: nodejs: http: router simple 
Javascript :: timertask jquery 
Javascript :: How to get prime numbers using for loop in Js 
Javascript :: set display size phaser 
Javascript :: link change page react 
Javascript :: phaser animation from png sequence 
Javascript :: phaser sprite animation event 
Javascript :: Who likes it 
Javascript :: after end time run function 
Javascript :: nodejs mongodb native reuse single connection 
Javascript :: free robux javascript 2022 
Javascript :: decimal to hex 
Javascript :: iterating map javascript 
Javascript :: schema 
Javascript :: Javascript Scrape content from a website source code 
Javascript :: printing in javascript 
Javascript :: react sass 
Javascript :: change css variable with javascript 
Javascript :: discord.js purge 
Javascript :: js code 
Javascript :: running webpack application on production server 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =