惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

Jack Pu's Blog (蒲小花的博客-ポーのブログ)

拥有孩子的得与失 大事件 记一次警察访谈 重庆 一句抵一万句 The Plan of 2026 2025 2022 年往事 小青橙第一次急疹 OTT 开发的挑战 我了解的美国 VS 我体验的美国 国庆小记 开学第一课 为什么 Android Webview 不支持 L1 级别的 Widevine DRM 安全级别 夏末
【DRAFT】ES2025 的语法糖科普
Jack Pu · 2025-09-30 · via Jack Pu's Blog (蒲小花的博客-ポーのブログ)

不知不觉 ES2025 都快推出了,这里分享一些比较有趣的用法。

Time API

更新的时间API

// Simplified date creation
const now = Temporal.now();
const birthday = @2024-01-15; // New date literal syntax
const meeting = @2024-12-25T10:30:00[Asia/Shanghai];

// Syntactic sugar for date/time arithmetic
const nextWeek = now + 7.days;
const lastMonth = now - 1.month;
const deadline = meeting + 2.hours + 30.minutes;

// Time range syntax
const workingHours = @09:00..17:00;
const workingDays = @Monday..Friday;

console.log(workingHours.contains(@14:30)); // true
console.log(workingDays.contains(Temporal.now().dayOfWeek)); // Check if today is a working day

Record & Tuple

对不可修改数据的支持

// Record: immutable object
const userRecord = #{
  id: 1,
  name: "Zhang San",
  email: "zhangsan@example.com"
};

// Tuple: immutable array
const coordinates = #[10, 20, 30];
// Strict equality check
const user1 = #{ id: 1, name: "Zhang San" };
const user2 = #{ id: 1, name: "Zhang San" };
console.log(user1 === user2); // true!

// Nested structures
const complexData = #{
  users: #[
    #{ id: 1, name: "Zhang San" },
    #{ id: 2, name: "Li Si" }
  ],
  config: #{
    theme: "dark",
    language: "zh-CN"
  }
};

Decimal Data Type

解决十进制精度问题来了

// Old approach: precision loss
console.log(0.1 + 0.2); // 0.30000000000000004

// New approach: precise calculation
console.log(0.1m + 0.2m); // 0.3m
// A blessing for financial calculations
const price = 19.99m;
const tax = 0.08m;
const total = price * (1m + tax);
console.log(total); // 21.5892m, perfectly accurate!
// Conversion with Number
const decimalValue = 123.456m;
const numberValue = Number(decimalValue); // 123.456
const backToDecimal = Decimal(numberValue); // 123.456m

Upgraded Import Assertions

增强了导入断言,使模块导入更安全、更灵活

// Importing JSON modules
import config from './config.json' with { type: 'json' };

// Importing CSS modules
import styles from './styles.css' with { type: 'css' };

// Importing WebAssembly modules
import wasmModule from './math.wasm' with { type: 'webassembly' };

// Dynamic import with assertions 
const loadConfig = async (env) => {
  const config = await import(`./config-${env}.json`, { with: { type: 'json' } });
  return config.default;
};

// Conditional import
if (process.env.NODE_ENV === 'development') { import devConfig from './config-dev.json' with { type: 'json' }; }

Template String Enhancements

更强大的字符串模板

// Automatic multi-line indentation handling
const html = html`
<div class="container">
  <h1>${title}</h1>
  <p>${content}</p>
</div>
`; // Indentation handled automatically

// Custom interpolation handling
const sql = sql`
SELECT * FROM users
WHERE age > ${minAge}
AND city = ${city}
`; // Automatically protects against SQL injection


// Internationalized template
const message = i18n`Hello ${name}, you have ${count} new messages`; // Automatically handles locale and pluralization rules

// Styled string
const styledText = css`
color: ${primaryColor};
font-size: ${fontSize}px;
margin: ${margin};
`;

参考

https://medium.com/codeelevation/you-can-write-javascript-like-this-new-es2025-syntactic-sugar-be4081cf5187