노마드코더/Vanilla JS

#2-1 너의 첫번째 함수! (Your first JS Function)

준승박 2021. 8. 28. 12:12

함수란 ?

함수(function)란 하나의 특별한 목적의 작업을 수행하기 위해 독립적으로 설계된 코드의 집합으로 정의할 수 있습니다.

 

대표적인 내장 함수 (console.log)

console.log(console)한 결과. 이 때 console은 Object이고, log는 함수이다. 

t {
  log: [Function],
  error: [Function],
  info: [Function],
  warn: [Function],
  dir: [Function],
  time: [Function],
  timeEnd: [Function],
trace: [Function],
  assert: [Function],
  clear: [Function],
  stdout: { [Function] clear: [Function] },
 _times: {} ...
}

함수 호출하기

function sayHello(name, age) {
  return `Hello ${name} you are ${age} years old`;
}
const gereeting = sayHello("park", 30);
console.log(gereeting); // Hello park you are 30 years old