Skip to content
Permalink
Browse files

added more clarifications on accessing default undefined values in JS…

… to CONTRIBUTING.md
  • Loading branch information
kroitor committed Oct 28, 2019
1 parent a647a95 commit 466b50f4aba3873d549aff60f3d420651d137bc1
Showing with 8 additions and 0 deletions.
  1. +8 −0 CONTRIBUTING.md
@@ -444,6 +444,14 @@ if some_dictionary.get('nonExistentKey'):

Most languages will not tolerate an attempt to access a non-existent key in an object.

For the above reasons, please, **never do this** in the transpiled JS files:

```JavaScript
// JavaScript
const value = object['key'] || other_value; // will not work in Python or PHP!
if (object['key'] || other_value) { /* will not work in Python or PHP! */ }
```

Therefore we have a family of `safe*` functions:

- `safeInteger (object, key)`, `safeInteger2 (object, key1, key2)`

0 comments on commit 466b50f

Please sign in to comment.
You can’t perform that action at this time.