Похожие чаты

What is difference between this 2 funtion function add(x,y){ return x+y; and this

const add = function(x,y){
return x+y;
?

11 ответов

34 просмотра

The difference is the first one gets hoisted.

not much, really

Plato- Автор вопроса
Plato- Автор вопроса
drunktimelord
not much, really

should we define like const or without const?

https://lmgtfy.app/?q=difference+between+function+declaration+and+function+expression

I read that the difference is that one is function declaration (without const) and the other one is a function expression (with const). "Function declarations load before any code is executed while Function expressions load only when the interpreter reaches that line of code."

Hoisting means that function declarations (without const) get moved to the top of the code. This way you can call a function anywhere within your code: console.log(myFn()); //works fine! //Even when we write the function later 👇🏽 function myFn(){ return "hello"; }

1001111 1101101 1100001 1110010
Hoisting means that function declarations (without...

It get moved to the top of the block it's in, which means one level up in the nesting chain, not necessarily to the top of the code. ✌️

1001111 1101101 1100001 1110010
Hoisting means that function declarations (without...

It gets moved to one of the blocks higher up, which means some levels up in the nesting chain, not necessarily to the top of the code. ✌️

Plato- Автор вопроса

if you say we can't change the const variables and any const! but why here we changed the const arrays? without no error const colors_1 = ["red", "blue", "green"]; const colors_2 = ["black", "white", "teal"]; const colors_3 = colors_1.concat(colors_2); console.log(colors_3);

Plato
if you say we can't change the const variables and...

you didn't change any constant here. just an expression that gets evaluated & stored in the colors_3 variable.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта