Diferans ant `let`, `const` ak `var` an JavaScript

poze a month ago187 gadeht

5

Mwen wè kòd ak var, let ak const. Ki lè pou m sèvi ak chak youn? Èske gen yon rezon pou toujou evite var?

🤖 Dyagnostik IA

Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.

poze a month ago

2 Repons

6
Repons yo aksepte

Your CMD npm start runs in a shell that exits. Also you're missing EXPOSE and a proper working directory. Try:

WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["node", "server.js"]

Exec form (["node", ...]) keeps the process as PID 1.

Konekte pou di lòt moun si li te mache.

answered a month ago
5

Rule of thumb: const by default, let when you must reassign, never var. var is function-scoped and hoisted, which causes subtle bugs. const doesn't make objects immutable — only the binding.

Konekte pou di lòt moun si li te mache.

answered a month ago

Sign in and verify your email to post an answer.