함수를 변수 변경에 바인딩하는 방법을 찾고 있습니다.변수가 변경 될 때 함수 호출
var arr = [],
str = 'hello';
onChange(arr, console.log);
onChange(str, console.log);
arr.push('element'); // console output: ["element"]
str += ' stack over flow'; // console output: "hello stack overflow"
- 이와 비슷한 형식입니다.
순수 JS 또는 jQuery로 작성된 kinda-mini-framework가 있습니까?
[자바 스크립트에서 변수 변경 감지] (http://stackoverflow.com/questions/1759987/detect-variable-change-in) -javascript) –
그래, 그와 비슷한 것이 필요하지만 배열 변경 사항을 추적 할 수있는 능력이 필요하다. (overwriting 된 .push() 및 다른 방법을 통해). – eXtractor