Use just string and symbol keys in objects #19

Closed
opened 2024-04-05 11:34:18 +00:00 by TopchetoEU · 1 comment
TopchetoEU commented 2024-04-05 11:34:18 +00:00 (Migrated from github.com)

Currently the objects can have any keys (objects, arrays, null, undefined, etc.). However, this could lead to multiple issues when executing ES5 code, for example:

// Example 1:
var obj = { true: 10 };
console.log(obj[true]); // undefined in this engine

// Example 2:
var key = { toString: function () { console.log('stringified'); return 'test'; } };
var obj = { test: 10 };
console.log(obj[key]); // key.toString won't get called, because no string conversion is done

From my experience with working with this engine, this isn't a problem 99% of the times, but doesn't provide too much of an advantage either. Ponder whether or not its worth it to sacrifice ES5 compliance for such little tradeoff

Currently the objects can have any keys (objects, arrays, null, undefined, etc.). However, this could lead to multiple issues when executing ES5 code, for example: ```js // Example 1: var obj = { true: 10 }; console.log(obj[true]); // undefined in this engine // Example 2: var key = { toString: function () { console.log('stringified'); return 'test'; } }; var obj = { test: 10 }; console.log(obj[key]); // key.toString won't get called, because no string conversion is done ``` From my experience with working with this engine, this isn't a problem 99% of the times, but doesn't provide too much of an advantage either. Ponder whether or not its worth it to sacrifice ES5 compliance for such little tradeoff
TopchetoEU commented 2024-09-04 12:59:30 +00:00 (Migrated from github.com)

The issue is fixed in the ES6 support branch

The issue is fixed in the ES6 support branch
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: topchetoeu/j2s#19
No description provided.