You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 20, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: src/conditional-compilation/index.md
+9-12Lines changed: 9 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
# Conditional Compilation
2
2
3
-
Both .NET and Rust are providing the possibility for compiling specific code
3
+
Both JavaScript and Rust are providing the possibility for compiling specific code
4
4
based on external conditions.
5
5
6
-
In .NET it is possible to use the some [preprocessor directives][preproc-dir] in
7
-
order to control conditional compilation
6
+
JavaScript doesn't support conditional compilation natively. However, it is possible to use some third-party tool like [`babel-plugin-preprocessor`][preproc-dir] in
7
+
order to control conditional compilation.
8
8
9
-
```csharp
10
-
#ifdebug
9
+
```js
10
+
//#if DEBUG
11
11
Console.WriteLine("Debug");
12
-
#else
12
+
//#else
13
13
Console.WriteLine("Not debug");
14
-
#endif
14
+
//#endif
15
15
```
16
16
17
17
In addition to predefined symbols, it is also possible to use the compiler
@@ -22,9 +22,6 @@ In Rust it is possible to use the [`cfg attribute`][cfg],
22
22
the [`cfg_attr attribute`][cfg-attr] or the
23
23
[`cfg macro`][cfg-macro] to control conditional compilation
24
24
25
-
As per .NET, in addition to predefined symbols, it is also possible to use the
26
-
[compiler flag `--cfg`][cfg-flag] to arbitrarily set configuration options
27
-
28
25
The [`cfg attribute`][cfg] is requiring and evaluating a
Copy file name to clipboardExpand all lines: src/environment-and-configuration/index.md
+31-10Lines changed: 31 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,32 @@
2
2
3
3
## Accessing environment variables
4
4
5
-
.NET provides access to environment variables via the
6
-
`System.Environment.GetEnvironmentVariable` method. This method retrieves the
7
-
value of an environment variable at runtime.
5
+
JavaScript doesn't provide access to environment variables natively. However, some non-browser JavaScript runtimes, such as Node.js and Node provides access to environment variables.
6
+
7
+
In Node.js:
8
+
9
+
```js
10
+
constname="EXAMPLE_VARIABLE";
11
+
12
+
let value =process.env[name];
13
+
if (!value) {
14
+
console.log(`Variable '${name}' not set.`);
15
+
} else {
16
+
console.log(`Variable '${name}' set to '${value}'.`);
17
+
}
18
+
```
19
+
In Deno:
20
+
21
+
```js
22
+
constname="EXAMPLE_VARIABLE";
23
+
24
+
let value =Deno.env.get(name);
25
+
if (!value) {
26
+
console.log(`Variable '${name}' not set.`);
27
+
} else {
28
+
console.log(`Variable '${name}' set to '${value}'.`);
29
+
}
30
+
```
8
31
9
32
```csharp
10
33
usingSystem;
@@ -68,14 +91,10 @@ fn main() {
68
91
}
69
92
```
70
93
71
-
In .NET a compile time access to environment variables can be achieved, in a
72
-
less straightforward way, via [source generators][source-gen].
0 commit comments