Environment Variables Flashcards

1
Q

What is an environment variable and what is its purpose in software development?

A

An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are used in software development to manage configurable values separate from code, such as API keys, database connections, or operational settings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you access environment variables in projects using modern bundlers like Vite?

A

In Vite, you can access environment variables by prefixing them with VITE_ in your .env file, and then using import.meta.env.VITE_YOUR_VARIABLE in your JavaScript to access the value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How and when should you define a new environment variable for a project?

A

Define a new environment variable when you need to manage values that vary between environments (development, testing, production) or need to be kept secure. Set them in your environment or .env file before your application starts, and ensure they are documented for other developers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How are environment variables used when deploying applications in containers?

A

When deploying with containers, you can specify environment variables in the container’s configuration file (like Docker’s Dockerfile or docker-compose.yml). These variables can be passed into the container at runtime, allowing configuration changes without modifying the container image.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a feature flag?

A

A feature flag is a technique to enable or disable functionality of an application without deploying new code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When to use a feature flag?

A

Use feature flags when you want to test new features safely in production, provide features to specific users, or maintain multiple feature variants in live environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly