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

posée a month ago189 vuesht

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?

🤖 Diagnostic IA

Généré par IA. Ce n'est pas une réponse — la communauté ci-dessous le confirme ou le corrige. Vérifiez toujours avant de vous y fier.

posée a month ago

2 réponses

6
Réponse acceptée

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.

Connectez-vous pour dire si ça a marché.

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.

Connectez-vous pour dire si ça a marché.

answered a month ago

Sign in and verify your email to post an answer.