Похожие чаты

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 ответов

16 просмотров

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.

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

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

Hey everyone! I won’t focus too much on what this person said (it’s clear they don’t understand the scope of what TF and TELOSX are achieving), but I’ll put it simply for thos...
Ana Ojeda
3
Hi did any of you experience a file error when download hex file for Windows?
Valya
17
как правильно удалить сддм? прописал в etc/portage.use/plasma-meta -sddm , но при обновлении юзов мне предлагает поставить lightdm (ещё лучше 😡), добавил туда - display-manage...
REDis
25
Коллеги, я тут для личных нужд пошел ставить MQTT сервер, пощупал mosquitto, но ужаснулся отсутствию такой банальности, как HTTP API для посмотреть список топиков. А тут что,...
Maksim Lapshin
13
How will they work it out?
Max
14
Could the new Norse labs apps have just been called "VPN" instead of DVPN?
HDGVII
14
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
Hello team, I have a question regarding next text from an article and if Energyweb is still working on EW-DOS or what the plans are for the future regarding EW-DOS? Can an...
MichelLWD
4
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
#include <stdio.h> #include <stdlib.h> #include <time.h> void mass_first_generate(int mass[5][7]) {     for (int N = 0; N < 5; N++) {         for (int A = 0; A < 7; A++) {   ...
Чувак
6
Карта сайта