
함수
특정 동작(기능)을 수행하는 일부 코드의 집합(부분)
function
function helloFunc() {
console.log(1234);
}
helloFunc();
function returnFunc() {
return 123;
}
let a = returnFunc();
console.log(a);
function sum(a, b) {
return a + b;
}
let a = sum(1, 2);
let b = sum(7, 12);
let c = sum(2, 4);
console.log(a, b, c);
function hello() {
console.log('Hello~');
}
let world = function () {
console.log('World~');
}
hello();
world();
const jason = {
name = 'JASON',
age = 24,
getName = function () {
return this.name;
}
};
const hisName = Jason.getName();
console.log(hisName);
console.log(jason.getName());