Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js proxy track nested object

var validator = {
  get(target, key) {
    if (typeof target[key] === 'object' && target[key] !== null) {
      return new Proxy(target[key], validator)
    } else {
      return target[key];
    }
  },
  set (target, key, value) {
    console.log(target);
    console.log(key);
    console.log(value);
    return true
  }
}


var person = {
      firstName: "alfred",
      lastName: "john",
      inner: {
        salary: 8250,
        Proffesion: ".NET Developer"
      }
}
var proxy = new Proxy(person, validator)
proxy.inner.salary = 'foo'
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs mysql escaping query 
Javascript :: how to change text of paragraph on click in java scriopt 
Javascript :: how to convert numbers to roman numerals in javascript 
Javascript :: write "hello world" 
Javascript :: copy multi cell value from one sheet to another using google app script 
Javascript :: devlop 
Javascript :: How to display html link inside table cell using reactjs material-table 
Javascript :: html vue input enabled 
Javascript :: javascript reduce form object 
Javascript :: class angular dynamic template 
Javascript :: laravel , json Why it shows Cannot access offset of type string on string error 
Javascript :: Javascript: Trying to make text randomly generate 
Javascript :: document.querySelectorAll(".preview") + forEach 
Javascript :: angularjs Both outer and inner divs have ng-click and when I click on the inner div, both ng-clicks execute. How to prevent that 
Javascript :: angularjs How to get time difference from ZoneDateTime in javascript 
Javascript :: AngularJS Pagination not showing all pages 
Javascript :: AngularJS slick carousel filter by attribute 
Javascript :: Syntax for npx 
Javascript :: Save multiple radios checked on LocalStorage 
Javascript :: react select disable 
Javascript :: style dropdown react native picker 
Javascript :: saves javascript 
Javascript :: audio js fast 
Javascript :: angular 13 deploy on tomcat 9 
Javascript :: how to install ghost js 
Javascript :: minus function 
Javascript :: cannot setState in event handler 
Javascript :: Create A Class That Returns A Promise In Constructor 
Javascript :: react js css style border 
Javascript :: load limited data and search data from all in angularjs 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =