javascript

javascript 메소드의 불변성 확인 사이트 : Does it mutate?

개발자먼지 2023. 11. 28. 17:35
반응형

javascript 메소드의 불변성을 확인해주는 사이트

Does it mutate?

 

Does it mutate?

The lastIndexOf() method returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex.Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )

doesitmutate.xyz

 

mutate : 변형되다

객체나 리스트 내에 변형을 일으키는 메소드는 === 불변성을 유지해주지않는다고 말할 수 있다.

 

예를 들어 push는 불변성을 유지해주지 않는다.

 

 

 

map 이나 filter 메소드는 원본 배열을 바꾸지 않고 새로운 배열을 리턴하므로 불변성을 유지해준다.

 

반응형