함수
function
function hello1(){
console.log('hello1');};
console.log(hello1, typeof hello1);
function hello2(name){
console.log('hello', name);};
function hello3(name){
return `hello3 ${name}`;};
console.log(hello3('Mark'));
const hello1 = function(){
console.log('hello1');};
console.log(hello1, typeof hello1);
const hello2 = function(name){
console.log('hello2', name);};
const hello3 = function(name){
return `hello3 ${name}`;};
hello1();
hello2();
hello3();
function hello1(){
console.log('hello1');}
var hello2 = function(){
console.log('hello2');}
const hello3 = function(){
consoloe.log('hello3');}
생성자
- const hello = new Function();
(자주 쓰이지는 않는다)
const sum = new Function('a','b','c','return a+b+c');
console.log(1,2,3);
- function / new Function 차이점
{
const a = 1;
const test = new Function('return a');
console.log(test());
}
const a = 2;
const test = function(){return a;};
console.log(test());
const hello1 = () => {console.log('hello1');};
const hello2 = name => {
console.log('hello2', name);};
const hello3 = (name, age) => {
console.log('hello2', name, age);};
const hello4 = name => {
return `hello4 ${name}`;};
const hello5 = name => `hello5 ${name}`;