ECMA 2025: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Created page with "=Introduction= Not much to say here - hi =Promise.try= Allow you to return a promise from a function <syntaxhighlight lang="js"> Promise.try(func) </syntaxhighlight> =New Set Functions= Loving the diagram for Mr dyslexic.<br> File:Set functions.png"
 
No edit summary
Line 9: Line 9:
Loving the diagram for Mr dyslexic.<br>
Loving the diagram for Mr dyslexic.<br>
[[File:Set functions.png]]
[[File:Set functions.png]]
=RegExp=
This has been changed but I never understand it. Thanks to robots don't need too. But the RegEx.escape look nice.
=Import=
The '''with''' keyword is now supported e.g. 
<syntaxhighlight lang="js">
import styles from "./styes.css" with { type:" "css"}
import data from "./data.json" with { type:" "json"}
</syntaxhighlight>
=Iterator=
Been update to support map, take, filter. I really like these but never seen people use them, only libraries. But here is an example.
<syntaxhighlight lang="js">
function* naturals() {
    let i = 0
    while(true) {
        yield i;
        i += 1
    }
}
const result = naturals()
    .map(value => {
        return value * value
    })
result.next() // value: 0, done:  false)
result.next() // value: 1, done:  false)
result.next() // value: 4, done:  false)
</syntaxhighlight>

Revision as of 01:43, 19 June 2025

Introduction

Not much to say here - hi

Promise.try

Allow you to return a promise from a function

Promise.try(func)

New Set Functions

Loving the diagram for Mr dyslexic.

RegExp

This has been changed but I never understand it. Thanks to robots don't need too. But the RegEx.escape look nice.

Import

The with keyword is now supported e.g.

import styles from "./styes.css" with { type:" "css"}
import data from "./data.json" with { type:" "json"}

Iterator

Been update to support map, take, filter. I really like these but never seen people use them, only libraries. But here is an example.

function* naturals() {
    let i = 0
    while(true) {
        yield i;
        i += 1
    }
}

const result = naturals()
    .map(value => {
        return value * value
    })

result.next() // value: 0, done:  false)
result.next() // value: 1, done:  false)
result.next() // value: 4, done:  false)