Section 3 Function

Jayden·2021년 1월 14일

JavaScript Studying

목록 보기
3/11
Fucntion

is  simply piece of code that we can reuse.
ex) logger();
this process here of basically using the function is called invoking the function, running the function or calling the function.
// calling/running/ invoking function

and with this, we can return any value from the function and so let's actually return the juice that we just produced
and so this value that we then return can be used anywhere later in our code.
So basically this juice will become the result of executing this function and let's actually do that.

fruitProcessor(5,0) 

the result of calling this function here will be the juice value that was just returned, okay?

And then we need to save that value somewhere we need to capture it
and we do that by basically saving it into this apple juice variable

이렇게해도

juice with 5 apples and 0 oranges 라고 나온다.
//
the only difference is that in this case here we did not capture the value into any variable.

Two way Function declaration /  Function expression


3-1
why 'use strict' ?
->First, strict mode forbids us to do certain things and
second, it will actually create visible errors for us in certain situations in which without strict mode
JavaScript will simply fail silently without letting us know that we did a mistake.

Arrow function


So that's the scenario when we have one parameter here(birthYear) and then more than one line of code basically.

And remember, in that situation, we need the return statement here.

--
Calling a function inside a function: Data Flow



unshfit -> 맨앞에 배열 추가할때
pop -> 맨 마지막꺼 지울때
shift -> 맨앞에 지울때

includes  is ES6

Object
And so let's now fill up this object with key value pairs.  So the key is basically the variable name.

Now each of these keys is also called a property.
So we say that this object here,  which is called Jonas has five properties.

profile
G'day mate!

0개의 댓글