Merge pull request #772 from influxdata/flux/object-string-syntax

Flux bracket notation and object properties
pull/777/head
Scott Anderson 2020-02-21 09:47:58 -07:00 committed by GitHub
commit 57a4b76767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 4 deletions

View File

@ -61,10 +61,10 @@ this is a string
Flux also supports objects. Each value in an object can be a different data type.
```js
> o = {name:"Jim", age: 42}
> o = {name:"Jim", age: 42, "favorite color": "red"}
```
Use dot notation to access a properties of an object:
Use **dot notation** to access a properties of an object:
```js
> o.name
@ -73,8 +73,24 @@ Jim
42
```
### Lists
Flux supports lists. List values must be the same type.
Or **bracket notation**:
```js
> o["name"]
Jim
> o["age"]
42
> o["favorite color"]
red
```
{{% note %}}
Use bracket notation to reference object properties with special or
white space characters in the property key.
{{% /note %}}
### Arrays
Flux supports arrays. All values in an array must be the same type.
```js
> n = 4