useEffect(() => {
xxx
}, [Object, string])
- 如上面代码,useEffect通过监听Object(对象参数)和string(字符串参数)的改变,来执行副作用;
- 比较一个复杂的对象是否相等,和比较一个字符串是否相等,字符串是否性能更优?
var a = 'hellowroldhellowroldhellowroldhellowroldhellowrold'
var b = a;
console.time('string');
Object.is(a, b);
console.timeEnd('string'); // 0.004150390625ms
a = {}
b = a;
console.time('object');
Object.is(a, b);
console.timeEnd('object'); // 0.001953125ms