Skip to content

Commit

Permalink
Fix multiple interactive example issues (#38175)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena authored Feb 16, 2025
1 parent fec5ea2 commit e439cd7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ The **`Date.parse()`** static method parses a string representation of a date, a
{{InteractiveExample("JavaScript Demo: Date.parse()")}}

```js interactive-example
const unixTimeZero = Date.parse("01 Jan 1970 00:00:00 GMT");
// Standard date-time string format
const unixTimeZero = Date.parse("1970-01-01T00:00:00Z");
// Non-standard format resembling toUTCString()
const javaScriptRelease = Date.parse("04 Dec 1995 00:12:00 GMT");

console.log(unixTimeZero);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,17 @@ browser-compat: javascript.builtins.RegExp.unicode

The **`unicode`** accessor property of {{jsxref("RegExp")}} instances returns whether or not the `u` flag is used with this regular expression.

{{InteractiveExample("JavaScript Demo: RegExp.prototype.unicode", "taller")}}
{{InteractiveExample("JavaScript Demo: RegExp.prototype.unicode")}}

```js interactive-example
const regex1 = new RegExp("\u{61}");
const regex2 = new RegExp("\u{61}", "u");
const regex1 = new RegExp("\\u{61}");
const regex2 = new RegExp("\\u{61}", "u");

console.log(regex1.unicode);
// Expected output: false

console.log(regex2.unicode);
// Expected output: true

console.log(regex1.source);
// Expected output: "a"

console.log(regex2.source);
// Expected output: "a"
```

## Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ browser-compat: javascript.builtins.RegExp.unicodeSets

The **`unicodeSets`** accessor property of {{jsxref("RegExp")}} instances returns whether or not the `v` flag is used with this regular expression.

{{InteractiveExample("JavaScript Demo: RegExp.prototype.unicodeSets")}}

```js interactive-example
const regex1 = new RegExp("[\\p{Lowercase}&&\\p{Script=Greek}]");
const regex2 = new RegExp("[\\p{Lowercase}&&\\p{Script=Greek}]", "v");

console.log(regex1.unicodeSets);
// Expected output: false

console.log(regex2.unicodeSets);
// Expected output: true
```

## Description

`RegExp.prototype.unicodeSets` has the value `true` if the `v` flag was used; otherwise, `false`. The `v` flag is an "upgrade" to the [`u`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode) flag that enables more Unicode-related features. ("v" is the next letter after "u" in the alphabet.) Because `u` and `v` interpret the same regex in incompatible ways, using both flags results in a {{jsxref("SyntaxError")}}. With the `v` flag, you get all features mentioned in the `u` flag description, plus:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@ You can also define async generator functions using the [`async function*` decla
{{InteractiveExample("JavaScript Demo: Expressions - Async Function Asterisk", "taller")}}

```js interactive-example
async function* foo() {
yield await Promise.resolve("a");
yield await Promise.resolve("b");
yield await Promise.resolve("c");
}

let str = "";

async function generate() {
for await (const val of foo()) {
async function joinAll(generator) {
let str = "";
for await (const val of generator()) {
str = str + val;
}
console.log(str);
return str;
}

generate();
const str = generate(async function* () {
yield await Promise.resolve("a");
yield await Promise.resolve("b");
yield await Promise.resolve("c");
});
console.log(str);
// Expected output: "abc"
```

Expand Down

0 comments on commit e439cd7

Please sign in to comment.