mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
docs(coding-convention): if-statements examples not respecting coding convention (#6786)
This commit is contained in:

committed by
Manol Donev

parent
0a1e7dabaa
commit
9df90afdd9
@ -279,7 +279,7 @@ if (a) return "winning";
|
|||||||
|
|
||||||
```TypeScript
|
```TypeScript
|
||||||
|
|
||||||
if(condition) {
|
if (condition) {
|
||||||
console.log("winning");
|
console.log("winning");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,15 +293,15 @@ if (!condition) {
|
|||||||
|
|
||||||
```TypeScript
|
```TypeScript
|
||||||
|
|
||||||
if(condition === true) {
|
if (condition === true) {
|
||||||
console.log("losing");
|
console.log("losing");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(condition !== true) {
|
if (condition !== true) {
|
||||||
console.log("losing");
|
console.log("losing");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(condition !== false) {
|
if (condition !== false) {
|
||||||
console.log("losing");
|
console.log("losing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ Do not use the **Yoda Conditions** when writing boolean expressions:
|
|||||||
|
|
||||||
```TypeScript
|
```TypeScript
|
||||||
let num;
|
let num;
|
||||||
if(num >= 0) {
|
if (num >= 0) {
|
||||||
console.log("winning");
|
console.log("winning");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -323,14 +323,14 @@ if(num >= 0) {
|
|||||||
|
|
||||||
```TypeScript
|
```TypeScript
|
||||||
let num;
|
let num;
|
||||||
if(0 <= num) {
|
if (0 <= num) {
|
||||||
console.log("losing");
|
console.log("losing");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**NOTE** It is OK to use constants on the left when comparing for a range.
|
**NOTE** It is OK to use constants on the left when comparing for a range.
|
||||||
```TypeScript
|
```TypeScript
|
||||||
if(0 <= num && num <= 100) {
|
if (0 <= num && num <= 100) {
|
||||||
console.log("winning");
|
console.log("winning");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user