# Cascading strings to numbers on shorthand object creation

**URL:** <https://es.discourse.group/t/cascading-strings-to-numbers-on-shorthand-object-creation/484>\
**Category:** 💡 Ideas\
**Created:** [September 25, 2020, 5:58pm UTC](https://es.discourse.group/t/cascading-strings-to-numbers-on-shorthand-object-creation/484 "2020-09-25T17:58:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsntngr](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/hsntngr/32/379_2.png) [@hsntngr](https://es.discourse.group/u/hsntngr)\
**Post date:** [September 25, 2020, 5:58pm UTC](https://es.discourse.group/t/cascading-strings-to-numbers-on-shorthand-object-creation/484/1 "2020-09-25T17:58:29Z")

</div>

How would it be cascading strings into number when we create an object with shortened syntax.

Instead of

`const user = {name, surname, age: +age, email};`

we could say

`const user = {name, surname, +age, email};`

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [September 26, 2020, 6:50am UTC](https://es.discourse.group/t/cascading-strings-to-numbers-on-shorthand-object-creation/484/2 "2020-09-26T06:50:23Z")

</div>

What if I want to cast it to a BigInt, or a String, or something else?

---

<div class="post-metadata">

**Author:** ![hsntngr](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/hsntngr/32/379_2.png) [@hsntngr](https://es.discourse.group/u/hsntngr)\
**Post date:** [September 26, 2020, 1:40pm UTC](https://es.discourse.group/t/cascading-strings-to-numbers-on-shorthand-object-creation/484/3 "2020-09-26T13:40:40Z")

</div>

@ljharb you are asking the right question but not under the right thread I guess. I only ask about string to number cascading.

But it would be great having easier syntax for string or bigint cascading. Turning numbers into string with an expression like a quote end of it

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [September 26, 2020, 4:50pm UTC](https://es.discourse.group/t/cascading-strings-to-numbers-on-shorthand-object-creation/484/4 "2020-09-26T16:50:33Z")

</div>

I think it would be very strange to create additional syntax weight for just casting to Number when so many other type conversions are also common.

---

<div class="post-metadata">

**Author:** ![hsntngr](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/hsntngr/32/379_2.png) [@hsntngr](https://es.discourse.group/u/hsntngr)\
**Post date:** [September 26, 2020, 5:48pm UTC](https://es.discourse.group/t/cascading-strings-to-numbers-on-shorthand-object-creation/484/5 "2020-09-26T17:48:06Z")

</div>

@ljharb I think it would be practical and aesthetic, nowadays most of people using state management systems and making primary key based comparison which is widely integer. It looks little annoying to watch while you define all your model in shorthand
