테스트 사이트 - 개발 중인 베타 버전입니다

javascript 라이브러리 로다쉬 - 배열,객체, 문자열 관련 유용한 라이브러리

· 3년 전 · 1449

아시는분이 많을거라 생각하고 있습니다.

배열,객체, 문자열 관련 자바스크립트 유용한 라이브러리인 로다쉬를 소개를 하려고합니다.

 

CDN 설치

로다쉬 CDN 리스트 경로 https://www.jsdelivr.com/package/npm/lodash

 

해동 경로로 이동하셔서 카피를 누르면 태그가 복사됩니다.

 

 

[code]

<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js" integrity="sha256-qXBd/EfAdjOA2FGrGAG+b3YBn2tn5A6bhz+LSgYD96k=" crossorigin="anonymous"></script>

[/code]

 

패키지 설치

 

[code]

npm install --save lodash

[/code]

 

_.findIndex(array, [predicate=_.identity], [fromIndex=0])
=>배열에서 인덱스 리턴에 사용

 

[code]

var users = [ { 'user': 'barney', 'active': false }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': true } ]; _.findIndex(users, function(o) { return o.user == 'barney'; }); // => 0 // The `_.matches` iteratee shorthand. _.findIndex(users, { 'user': 'fred', 'active': false }); // => 1 // The `_.matchesProperty` iteratee shorthand. _.findIndex(users, ['active', false]); // => 0 // The `_.property` iteratee shorthand. _.findIndex(users, 'active'); // => 2

[/code]

 

_.uniq(array)

=>배열의 중복 값을 제거 , 각 요소의 첫 번째 항목만 유지

 

[code]

_.uniq([2, 1, 2]);

// => [2, 1]

[/code]

 

자세한 정보 : https://lodash.com/

 

 

 

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
16619
16618
16612
16603
16598
16589
16578
16571
16563
16554
16546
16534
16527
16520
16513
16510
16505
16498
16490
16486
16482
16465
16458
16456
16448
16447
16440
16439
16438
16430