Section 11: Working With Arrays

Jayden·2021년 2월 17일

JavaScript Studying

목록 보기
9/11
post-thumbnail

141. Simple Array Methods

And so what we can see is that splice actually does mutate the original array, so it takes part of the array and returns it and then the original array itselfloses this part that was extracted.



Reverse하면 arr2가 아예 바뀜

Concat = 합치는것

142. Looping Arrays: forEach



둘이 똑같은 결과

abs is absoulte value 절대값


foreach에서 파라미터 값 순서대로 (element ,index, array) 정의되어있음.

  1. forEach With Maps and Sets

USD is Key , Unted states dollar is Value

  1. PROJECT: "Bankist" App
    10min
  2. Creating DOM Elements

afterbegin 8번부터
beforeend: 1번부터

  1. Coding Challenge #1
    9min

147. Data Transformations: map, filter, reduce

148. The map Method


--> same result.

const movementsUSD = movements.map(mov =>
mov * eurToUsd);

  1. Computing Usernames

console result = stw


arrow function에 return이 있음.

forEach를 써야함 왜냐하면
because again, we do not want to create a new array,

we simply want to modify basically, the array that we get as an input.

And then on the other hand, the for each method, it was a great use case to produce some so called side effects.

So in other words, to simply do some work without returning anything.

And so that's what we did here, we simply looped over the accounts array, and in each iteration,

we manipulated the current account object, and edit a username to it based on the account owner,

plus all of these transformations that we had already done before.

  1. The filter Method

both are same results

arrow function 쓰면 mov<0 은 return이 생략되어있음

  1. The reduce Method

0 is initial value

같은 결과 3840

acc = accumulator

최대값 : 3000

So now our accumulator is at 200 and the current movement is at 450.

So this one here is false again. And so now we return to movement as the new accumulator in the next iteration.

All right. And so in the next iteration, that accumulator is 450 now, then here, the current movement is minus 400.

And so here is 450 greater than minus 400.

profile
G'day mate!

0개의 댓글