Source code
Revision control
Copy as Markdown
Other Tools
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
description: >
Destructuring initializer is not evaluated when value is an object
with [[IsHTMLDDA]] internal slot.
info: |
BindingPattern : ArrayBindingPattern
1. Let iteratorRecord be ? GetIterator(value).
2. Let result be IteratorBindingInitialization of ArrayBindingPattern with arguments
iteratorRecord and environment.
3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result).
4. Return result.
Runtime Semantics: IteratorBindingInitialization
SingleNameBinding : BindingIdentifier Initializer[opt]
[...]
5. If Initializer is present and v is undefined, then
[...]
6. If environment is undefined, return ? PutValue(lhs, v).
features: [destructuring-binding, IsHTMLDDA]
---*/
let initCount = 0;
const counter = function() {
initCount += 1;
};
const IsHTMLDDA = $262.IsHTMLDDA;
const [x = counter()] = [IsHTMLDDA];
assert.sameValue(x, IsHTMLDDA);
assert.sameValue(initCount, 0);
reportCompare(0, 0);