You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
value-equal이라는 라이브러리가 있다.
react-router-dom내부를 살펴보다가 history라는 npm 라이브러리에서 사용을 하고 있어서 열어보니 어느 타입이든 값이 같은지 비교를 해주는 라이브러리가 있었다. 하물며 Array의 값들이 같은지 Object안에 있는 값들이 같은지를 비교를 해준다.
실제로 내부는?
실질적으로 코드의 양은 엄청나게 적다는 것을 확인했다.
functionvalueOf(obj){returnobj.valueOf ? obj.valueOf() : Object.prototype.valueOf.call(obj);}functionvalueEqual(a,b){// Test for strict equality first.if(a===b)returntrue;// Otherwise, if either of them == null they are not equal.if(a==null||b==null)returnfalse;if(Array.isArray(a)){return(Array.isArray(b)&&a.length===b.length&&a.every(function(item,index){returnvalueEqual(item,b[index]);}));}if(typeofa==='object'||typeofb==='object'){varaValue=valueOf(a);varbValue=valueOf(b);if(aValue!==a||bValue!==b)returnvalueEqual(aValue,bValue);returnObject.keys(Object.assign({},a,b)).every(function(key){returnvalueEqual(a[key],b[key]);});}returnfalse;}
The text was updated successfully, but these errors were encountered:
나도 구현할 수 있겠는데?
value-equal이라는 라이브러리가 있다.
react-router-dom내부를 살펴보다가 history라는 npm 라이브러리에서 사용을 하고 있어서 열어보니 어느 타입이든 값이 같은지 비교를 해주는 라이브러리가 있었다. 하물며 Array의 값들이 같은지 Object안에 있는 값들이 같은지를 비교를 해준다.
실제로 내부는?
실질적으로 코드의 양은 엄청나게 적다는 것을 확인했다.
The text was updated successfully, but these errors were encountered: