ar
Not that different. You can usually translate one syntax to the other, but you
may need ES6 features like `new.target`, `super` or `setPrototypeOf`.
-- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
ess it's too late to change that. Maybe some day we will have
`Object.isConstructor`.
;Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
> I fixed it by putting the function inside `Object()`
You can also use the comma operator:
```js
var anon = (0, function () {});
anon.name; // ""
```
;Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.or
);
q.pop(); // 2
q.pop(); // 3
q.pop(); // undefined
```
-- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
"foo"); // true
delete obj.foo;
// [[HasProperty]] returns false
"foo" in obj; // false
```
-Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
vable own property
!!Object.getOwnPropertyDescriptor(p, "foo"); // true
// [[HasProperty]] returns false
"foo" in p; // false
```
-Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
Not only `size`. All `get`, `set`, `has`, etc. algorithms in the spec are O(n).
But as explained in
http://www.ecma-international.org/ecma-262/7.0/index.html#sec-map-objects,
> Map object must be implemented using either hash tables or other mechanisms
> that, on average,
> provide access times
0` is already
enough of a nightmare.
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
are proxies. Taking them into account, I don't think there is
any reasonable way to compare objects.
So I think it's better if each person writes the code that compares objects
according to their needs.
--Oriol
___
es-discuss mailing list
There is a `String#matchAll` proposal in stage 1.
https://github.com/tc39/String.prototype.matchAll<http://%20https://github.com/tc39/String.prototype.matchAll>
Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozil
e the need to add new syntax for this.
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
. Shouldn't `!` also be excluded, then?
> Future: Extending of operators
I don't think this can work if you don't define a way to determine the operands.
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
n arr; }
|> arr => arr.reduce((a, b) => a + b);
```
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
would expect this:
```js
let locked = Object.lock({});
let inherits = Object.create(locked);
Reflect.get(locked, "foo"); // TypeError
Reflect.get(locked, "foo", {}); // TypeError
Reflect.get({}, "foo", locked); // undefined
Reflect.get(inheri
Instead of `thrown: false` or `thrown: false`, why not `type: "normal"`, `type:
"return"` or `type: "throw"`? This is what completion records use.
-Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
ument, {}).nodeType; // TypeError: 'get nodeType' called on an
object that does not implement interface Node.
```
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
See https://esdiscuss.org/topic/strict-relational-operators
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
cause of the value they return, they can also have desirable side-effects.
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
like
```js
class FooBar extends Element {
constructor() {
console.log("patched in Element");
let el = document.createElement('foo-bar');
return Object.setPrototypeOf(el, FooBar.prototype);
}
}
```
-Oriol
___
es-discus
(2); // { arg: 2 }
```
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
Consider using an async function:
```js
async function promiseFunction() {
return someValue;
}
```
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
mmend something
more simple and reliable like
```js
function isObject(value) {
return Object(value) === value;
}
function isObject(value) {
return new function(){ return value } === value;
}
```
--Oriol
___
es-discuss mailing list
es-discuss@mozill
`addEventListener` in not part of ECMAScript. It's defined in the DOM spec. You
should send your proposal to the WHATWG.
--Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
arget.
- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
> I believe there's a very simple way to do this today: new Map([...mapA,
> ...mapB, ...mapC]).
But this only works if you want to create a new map, of course. Can't be used
to assign to an existing map.
- Oriol
___
es-discuss mailing
t;console.log(1);";
document.documentElement.appendChild(s);
console.log(2);
```
The output will be `1`, `2`. The script runs immediately, it's not async.
- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
block;
}
return action({ data: response.data });
}
```
- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
;, "has", "getOwnPropertyDescriptor"];
let handler = new Proxy(Object.create(null), {
get(_, trap, receiver) {
if (!allowed.includes(trap)) return error;
}
});
this.emit('some:event', new Proxy(obj, handler));
```
-- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
> the last point doesn't haven't the same usability as my proposal since with
> mine multiple different objects can be selected from at a time
I believe that you could use Bob's proposal like this:
```js
var obj = {...obj1.{prop1, prop2}, ...obj2.{prop3, p
Be aware your code breaks pair surrogates, which might be undesirable:
```js
var str = "a_\uD83D\uDE80_b";
str.split("").reverse().join(""); // "b_\uDE80\uD83D_a" :(
[...str].reverse().join(""); // "b_\uD83D\uDE80_a" :)
```
--Oriol
Hi Joe, I used a 2nd proxy as the handler in order to only allow the desired
traps.
Sure, I could have defined all blacklisted traps in an ordinary object, and
make them throw an error.
But this wouldn't be future-proof in case new traps are eventually added.
Whitelisting is safer.
--
;t read the handler spec in advance?
Yes, the spec does not allow this. But there was a proposal about doing that in
some cases, in order to improve performance.
-- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
.
And I don't really see the point, constructors are supposed to construct
objects. If you want primitives, you can always use function calls.
-- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
gt; function isObject(value) {
> return value != null && (
> typeof value === "object" ||
> typeof value === "function"
> )
> }
No, `typeof` is not reliable, because it's implementation-defined for
non-standard non-callable
Very obscure indeed.
-- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
7;lucas', 'matheus'];
const {compare} = new Intl.Collator(undefined, {sensitivity: "base"});
if (manyStrings.some(s => compare(s, stringOne) == 0)) {
// Yes, it was found
}
```
-- Oriol
pEpkey.asc
Description: pEpkey.asc
_
ne symbol
properties in property descriptors and read them later, ignoring the receiver
when calling getters and setters, assuming all objects are extensible and all
properties are configurable, etc.
--Oriol
pEpkey.asc
Description: pEpkey.asc
___
es
> About being unique, you can always
> `document.querySelector('[attribute="' + value +'"]')`
This code is vulnerable to CSS injection, input values shouldn't be
inserted raw into queries!
You can use `CSS.escape` to sanitize.
-- Oriol
_
If you want to add this you will need a champion, see
https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md#new-feature-proposals
-- Oriol
El 29/5/19 a les 21:15, Григорий Карелин ha escrit:
I agree.
So, what does community think? Do we want to have “destructuring picking” sugar
in JS
This sounds like https://github.com/tc39/proposal-pattern-matching
El 31/1/20 a les 10:57, Sultan ha escrit:
For example, the following:
switch (value) {
case 0...9: break
case 'a'...'z': break
}
___
es-discuss mailing list
es-discuss@mozilla
`foo' before
initialization
```
And `let` variables can't be redeclared:
```js
let foo = 123; // SyntaxError: redeclaration of let foo
```
Is this behaviour intended? Is there any way to take `foo` out of the TDZ, so
that I can assign values
They are no necessary the same:
```js
var _Object = window.Object,
Object = function() {};
class Foo1 {
constructor() {}
}
class Foo2 extends Object {
constructor() { super(); }
}
_Object.getPrototypeOf(Foo1.prototype); // _Object.prototype
_Object.getPrototypeOf(Foo2.prototype); // Object
`setTimeout` is not part of ECMAScript. You should suggest this to WHATWG
instead.
- Oriol
From: m...@adriansieber.com
Date: Mon, 25 Apr 2016 17:35:50 +
Subject: Proposal: Switch position of delay and callback in signature of
`setTimeout()`
To: es-discuss@mozilla.org
Everytime I
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: otakus...@gmail.c
I agree with Bergi.
> Brendan Eich and think he understood that fairly
I can't see that. He says things like "what's to propose?", "what is declare? I
don't think core language needs to grow", "What does this have to do with
promises?", "I don't see the point" and "It's not making sense, sorry.
Array.prototype.includes uses the second argument as the starting index.
Therefore, these calls would be identical, but you want them to behave
differently:
```
["a"].includes("a", 0); // true -- "a" can be found at position 0
["a"].includes(...["a", 0]); // false -- 0 can't be found in the arra
What's the point of using `reduce` instead of `every`?
```js
Array.prototype.includesAll = function (...args) {
return args.every(item => this.includes(item));
}
```
I disagree with this test
```js
expect([2, 3].includesAll()).toBe(false)
```
The array `[2,3]` includes all items in `[]`. So i
> There are no items in `[]` so that doesn't seem like a true statement to me.
It's true by [Vacuous_truth](https://en.wikipedia.org/wiki/Vacuous_truth).
> So, at least consistency pulls towards `false`.
You are misunderstanding what `includes` does when there is no argument.
```js
[1].includes
Probably, because symbols are primitive values, and constructors only create
and initialize objects.
So you are supposed to call it as a function instead of as a a constructor.
That said, it might make sense for `new Symbol()` to return a symbol object.
But instead, you can use
```javascrip
> Could there be a Proxy.hasBeenRevoked(proxy) method?
The Proxy constructor only accepts targets and handlers when they are objects
and are not revoked proxies.
I wonder what's the point of not allowing revoked proxies but allow revocable
proxies which may be revoked later.
Anyways, this al
add them only in sloppy mode, and Firefox to never add them. So
I think both follow the spec.
- Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
sure it will be a strict mode
function, it will be extensible, and won't have any additional non-configurable
own property. Then you will have less problems with proxy invariants.
-Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mai
orks like this:
```
(f ? g)(x) = f(g(x))
```
So I think it would be more intuitive to use `<=<`, which would call the right
operand first, and then call the left operand with the result of the right one.
,Oriol
___
es-discuss mailing list
es-disc
I like this proposal. Specially for `while` loops.
When I want to iterate all matches of a global regex, I always think the
variable declaration at the top seems ugly
```js
let match;
while (match = regex.exec(string)) {
// ...
}
```
This looks better:
```js
while (let match = regex.exec(str
I disagree with silently ignoring property access on null/undefined.
> Early errors are nice
Yes, exactly. Errors should fail early and loudly. That's why the strictness of
strict mode is useful.
> It's no weirder that `123.foo` not throwing.
No, it's entirely different, because numbers ar
ree. But as
Mike Samuel mentioned, JSON strings containing U+2028 or U+2029 are not valid
JS expressions. I think it would make sense for `JSON.stringify` to escape
these.
-Oriol
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozill
In my opinion it's a bit incoherent that each object-coercible type behaves
differently when coercing symbols to it.
Symbols can be explicitly coerced to strings, but not implicitly:
```js
String(Symbol("abc")); // "Symbol(abc)"
Symbol("abc") + ""; // TypeError
```
Symbols can't be coerced to n
Object literals (object initializers) are just a convenient way to create a new
ordinary object which (initially) inherits from `Object.prototype`, and
populate it with some properties.
I don't think you should be able to distinguish them from similar objects not
created using object initialize
Not sure if I'm missing something, but wouldn't it be trivial to code that
constructor in JS?
```js
class Result {
constructor (type, value=true) {
this[type] = value;
}
}
function add(data) {
if (data !== Object(data)) {
return new Result('error', new Error('The data is not an obj
59 matches
Mail list logo