Oriol Bugzilla (2016-05-26T09:35:07.000Z)
As Isiah Meadows said, you can just use variables.

```
var removeNode = true;
control.dispose(removeNode);
```

```
var silent = true,
      disableValidation = true,
      destroyOldValue = false;
model.set('foo', newValue, {silent, disableValidation, destroyOldValue});```
From: otakustay at gmail.com
Date: Thu, 26 May 2016 09:02:21 +0000
Subject: How about a "named true" and a "named true property"
To: es-discuss at mozilla.org

I don't really know how to name this feature, but I find it quite neccessary
In JavaScript land there are many functions with parameters of type boolean, and invocations to these functions do not have high readability, for example jQuery have a `clone` method with a parameter deep of type boolean, but when read a code like:
```$.clone(sourceObject, true);```
it's hard to understand what is that `true` stands for, a more unfamiliar API could make this more uncomfortable:
```control.dispose(true); // does it mean "to remove DOM node or anything else?"```
In practice we can write some comment after a boolean parameter to explain what it is:
```control.dispose(true /* removeNode */);```
but it's a lot of work.
In this case I think we may introduce a handy syntax called "named true" which only transforms to the keyword `true` but have a custom name:
```control.dispost(:removeNode);```
Here a leading colon hints it is a "named true" so in parsing stage `:removeNode` simply becomes `true`, and we can have a false value with simply `!:removeNode`, it doesn't hit performance but notably increase readability
Boolean parameters is not good practice but I believe it is not eliminated nowadays and will never be eliminated, so a more friendly syntax could save a lot of time
---
Furthermore, there are also many functions accepting an `options` parameter including some "flag properties", flag properties are simple properties with a boolean value, a good example is the {silent: true} flag in many event related APIs.
Constructing an `options` object containing flag properties are not easy, we may repeat `: true` and `: false` many times, so with previously "named true", I think a "named true property" could help to save time:
```model.set('foo', newValue, {:silent, :disableValidation, !:destroyOldValue})```
Here `:silent` is simply parsed to `silent: true` and `!:destroyOldValue` is for `destroyOldValue: false`, it can save a large amount of code
All syntax here are just examples, not any propose to grammar

_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160526/d0a8d91a/attachment.html>
oriol-bugzilla at hotmail.com (2016-05-26T09:43:40.241Z)
As Isiah Meadows said, you can just use variables.

```javascript
var removeNode = true;
control.dispose(removeNode);
```

```javascript
var silent = true,
      disableValidation = true,
      destroyOldValue = false;
model.set('foo', newValue, {silent, disableValidation, destroyOldValue});
```
oriol-bugzilla at hotmail.com (2016-05-26T09:40:04.583Z)
As Isiah Meadows said, you can just use variables.

```
var removeNode = true;
control.dispose(removeNode);
```

```
var silent = true,
      disableValidation = true,
      destroyOldValue = false;
model.set('foo', newValue, {silent, disableValidation, destroyOldValue});
```