Diferans ant `let`, `const` ak `var` an JavaScript
asked a month ago190 viewsht
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?
🤖 AI diagnosis
AI-generated. Not an answer — the community below confirms or corrects it. Always verify before relying on it.
asked a month ago
David Charles 407
2 Answers
6
✓✓ Accepted answer
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.
Sign in to tell others whether this worked.
answered a month ago
Patrick Alcin 918
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.
Sign in to tell others whether this worked.
answered a month ago
Nadège Paul 296
Sign in and verify your email to post an answer.