TL;DR: JavaScript ECMAScript 2024의 획기적인 기능을 살펴보세요. 이 가이드에서는 코딩 경험을 변화시키기 위해 고안된 최신 혁신 기술을 살펴봅니다. 간편한 데이터 그룹화를 위한 새로운 그룹별 방법부터 날짜 및 시간 관리를 단순화하는 판도를 바꾸는 Temporal API에 이르기까지 ECMAScript 2024에는 효율성과 정확성을 향상시키는 도구가 가득합니다.
ECMAScript는 JavaScript의 기본 구성 요소입니다. 1990년대 중반 이후 ECMAScript는 개발자에게 새로운 기능을 제공하고 웹 경험의 역동적이고 사용자 친화적인 특성을 강화하도록 발전했습니다. 간단한 스크립트부터 복잡한 프레임워크까지 디지털 환경에 영향을 미치고 웹 개발의 창의성과 혁신을 촉진합니다.
수년에 걸쳐 ECMAScript의 수많은 에디션이 출시되었으며 각 에디션에는 새로운 기능과 개선 사항이 포함되었습니다. 이 가이드에서는 최신 ECMAScript 2024(Edition 15)의 새로운 기능을 설명합니다. 코딩 방식을 혁신할 최신 기능을 탐색할 준비를 하세요!
groupBy 메소드를 사용하여 동기 Iterable 그룹화
자바스크립트 개발자는 특정 기준에 따라 데이터를 그룹으로 구성해야 하는 경우가 많습니다. ECMAScript 2024의 새로운 groupBy 메서드를 사용하면 이 작업이 쉬워집니다. 항목 컬렉션이 있고 이를 특정 속성으로 그룹화하고 싶다고 가정해 보세요. groupBy가 이를 위한 유용한 도구입니다!
그룹바이란 무엇인가요?
groupBy 메소드는 Object 및 Map에서 사용할 수 있는 정적 메소드입니다. 이를 통해 각 항목에서 파생된 키를 기반으로 컬렉션의 항목을 빠르고 효율적으로 그룹화할 수 있습니다. 결과는 각 키가 그룹에 해당하고 값은 해당 그룹에 속하는 항목의 배열인 새 개체입니다.
여러 사람이 있고 연령별로 그룹화하고 싶다고 가정해 보겠습니다. groupBy 방법
을 사용하여 이를 수행하는 방법은 다음과 같습니다.
const people = [ { name: "Alice", age: 25 }, { name: "Bob", age: 30 }, { name: "Charlie", age: 25 }, { name: "David", age: 30 }, { name: "Eve", age: 35 } ]; const groupedByAge = Object.groupBy(people, person => person.age); console.log(groupedByAge);
출력
{ "25": [ { "name": "Alice", "age": 25 }, { "name": "Charlie", "age": 25 } ], "30": [ { "name": "Bob", "age": 30 }, { "name": "David", "age": 30 } ], "35": [ { "name": "Eve", "age": 35 } ] }
Promise.withResolvers()
JavaScript Promise는 항상 비동기 작업 관리를 위한 믿음직한 동반자였습니다. 하지만 ECMAScript 2024에는 Promise.withResolvers()라는 새로운 도구가 있습니다. 이 강력한 정적 메서드는 Promise가 해결되건 거부되건 외부 코드에서 직접 Promise의 운명을 완벽하게 제어할 수 있는 열쇠를 제공합니다.
이 Promise.withResolvers() 함수는 세 가지 속성이 있는 객체, 즉 resolve 및 reject 함수를 사용하는 새로운 promise를 반환합니다. 그것과 관련이 있습니다.
사용자 입력에 따라 완료하거나 취소할 수 있는 작업을 관리한다고 가정해 보겠습니다. Promise.withResolvers() 함수를 사용하는 방법은 다음과 같습니다.
function createControllablePromise() { const { promise, resolve, reject } = Promise.withResolvers(); // Simulate an async task. setTimeout(() => { console.log("Task is pending..."); }, 1000); return { promise, resolve, reject }; } const { promise, resolve, reject } = createControllablePromise(); // Somewhere in your code, you can resolve or reject the promise. setTimeout(() => { resolve("Task completed successfully!"); // or if something goes wrong. reject("Task failed due to an error."); }, 3000); promise .then(result => console.log(result)) .catch(error => console.error(error));
일시적인
JavaScript의 Date API로 인해 어려움을 겪은 적이 있습니까? 꽤 어려울 수 있습니다.
ECMAScript 2024에서는 Temporal이라는 현대적이고 강력한 API가 날짜 및 시간 작업을 더욱 쉽고, 직관적이고, 정확하게 수행할 수 있도록 설계되었습니다. 판도를 바꾸는 이 API는 이전 Date 객체의 단점을 수정하고 다양한 새로운 기능을 제공합니다.
임시 API는 날짜와 시간을 처리하는 JavaScript의 새로운 방법입니다. 번거롭고 오류가 발생하기 쉬운 기존 Date API와 달리 Temporal은 더욱 정확하고 유연한 접근 방식을 제공합니다.
예를 들어 프로젝트 마감일을 오늘부터 90일로 계획하고 있다면 임시를 사용하면 정확한 날짜를 간단하게 계산할 수 있습니다.
다음 코드 예시를 참고하세요.
// Getting the current date in ISO format. const today = Temporal.Now.plainDateISO(); console.log(today.toString()); // Output: "2024-07-02" // Adding 90 days to the current date to calculate the deadline. const deadline = today.add({ days: 90 }); console.log(deadline.toString()); // Output: "2024-09-30" // Checking how many days remain until the deadline. const daysUntilDeadline = deadline.since(today).days; console.log(`Days until deadline: ${daysUntilDeadline}`); // Output: "Days until deadline: 90"
이 예에서는 임시가 작업 예약을 단순화하여 시간 기반 작업을 처리하는 JavaScript 개발자에게 필수적인 도구가 되는 방법을 보여줍니다.
정규식 v 플래그
ECMAScript 2024에는 정규식에 대한 새로운 개선 사항인 v 플래그가 도입되었습니다. 이 추가 기능을 통해 더욱 정교한 패턴 일치 및 문자열 조작이 가능해 개발자가 복잡한 텍스트 처리 작업을 더 효과적으로 제어할 수 있습니다.
v 플래그는 정규 표현식의 정확성과 표현력에 관한 것입니다. 특정 문자 그룹, 특히 특정 유니코드 속성을 가진 문자 그룹과 일치하는 패턴을 더 쉽게 정의할 수 있는 집합 표기법이 도입되었습니다. 즉, 더 정확하고 읽기 쉬운 정규식 패턴을 만들 수 있습니다.
정규 표현식에서 v 플래그를 사용하여 유니코드 속성을 기반으로 문자 집합을 일치시키는 방법을 살펴보겠습니다.
// Regular expression to match any character with the Unicode property "Letter" (L). const regex = /\p{L}/v; // Test string containing various Unicode characters. const testString = "abc123ΩΩß漢字"; // Matching all characters with the "Letter" property. const matches = [...testString.matchAll(regex)]; console.log(matches.map(match => match[0])); // Output: ["a", "b", "c", "Ω", "Ω", "ß", "漢", "字"]
Simplifying asynchronous code with Top-Level Await
The JavaScript ECMAScript 2024 introduces Top-Level Await, a game-changer for handling asynchronous operations at the module level. This feature eliminates the need to wrap your code in an async function, making your code more straightforward and easier to maintain.
Traditionally, await could only be used inside async functions, which meant you had to create wrapper functions for any asynchronous operations. Top-Level Await changes that by allowing you to use await directly within the top-level scope of a module. This makes handling asynchronous tasks such as fetching data or loading resources much easier when your module is first loaded.
// data.js const response = await fetch('https://api.example.com/data'); export const data = await response.json(); // main.js import { data } from './data.js'; console.log(data); // Logs the fetched data
Well-formed methods
Handling Unicode strings is crucial in a globalized web environment where apps must support multiple languages and symbols. ECMAScript 2024 introduces the concept of Well-formed Unicode Strings, which ensures that JavaScript handles Unicode data consistently and reliably across different environments.
A well-formed Unicode string follows the proper encoding rules, ensuring characters are represented correctly. Previously, malformed Unicode strings—those with invalid sequences—could lead to unexpected behavior or errors in JavaScript. This new feature helps to identify and correct these issues, making your code more robust.
Let’s see how you can check if a string is well-formed and how to correct a malformed string.
// Example of a well-formed Unicode string. const string1 = "Hello, InfoWorld!"; // Example of a malformed Unicode string. const string2 = "Hello, \uD800world!"; // \uD800 is an unpaired surrogate // Checking if strings are well-formed. console.log(string1.isWellFormed()); // Output: true (well-formed) console.log(string2.isWellFormed()); // Output: false (malformed) // Correcting the malformed string. console.log(string2.toWellFormed()); // Output: 'Hello, �world!'
In the above code example, we have used the following methods:
- isWellFormed(): To check whether the string is properly encoded according to Unicode standards. If the string contains any invalid sequences, it returns false.
- toWellFormed(): To return a new string where any malformed sequences are replaced with the Unicode replacement character � (Often referred to as the replacement character). This ensures the string is well-formed, even if it originally contained errors.
Conclusion
Thanks for reading! The ECMAScript 2024(Edition 15) introduces a range of powerful features that enhance JavaScript’s flexibility, reliability, and efficiency, making it even more equipped to handle modern web development challenges.
- Grouping synchronous iterables with the groupBy method offers an elegant way to categorize and manage data collections, simplifying data processing tasks.
- Promise.withResolvers method provides a more controlled and accessible way to handle asynchronous operations, offering developers a streamlined approach for managing promises in their code.
- Temporal API revolutionizes managing dates and times in JavaScript, offering a modern, precise, and user-friendly alternative to the traditional Date object.
- Top-Level Await simplifies asynchronous programming by allowing await to be used at the module level, making code cleaner and easier to understand.
- Regular Expression v Flag introduces new possibilities for complex pattern matching and string manipulation, empowering developers with more expressive and powerful regular expressions.
- Well-formed Unicode strings ensure that JavaScript handles text data consistently and accurately across different environments, safeguarding against data corruption and enhancing the reliability of internationalized apps.
These enhancements make JavaScript more robust and easier to use, positioning it as a more powerful tool for developing complex, modern web apps. By embracing these features, developers can write more maintainable, efficient, and error-resistant code, ensuring their apps are ready for the future of web development.
Syncfusion JavaScript UI components library is the only suite you will ever need to build an app. It contains over 85 high-performance, lightweight, modular, and responsive UI components in a single package.
If you are an existing customer, you can access the new version of Essential Studio from the License and Downloads page. For new customers, we offer a 30-day free trial so you can experience the full range of available features.
If you have questions, you can contact us through our support forum, support portal, or feedback portal. We are always happy to assist you!
관련 블로그
- JavaScript 쿼리 빌더를 사용하여 두 테이블을 조인하는 방법은 무엇입니까?
- 트래픽이 많은 웹사이트를 처리하기 위한 확장 가능한 Azure 정적 웹 앱 구축
- JavaScript 피벗 테이블에서 메모리 관리 최적화: 모범 사례 및 팁
- JavaScript 다이어그램 라이브러리를 사용하여 대화형 평면도 다이어그램을 쉽게 생성
위 내용은 JavaScript의 새로운 기능: ECMAScript 에디션의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

예, JavaScript의 엔진 코어는 C로 작성되었습니다. 1) C 언어는 효율적인 성능과 기본 제어를 제공하며, 이는 JavaScript 엔진 개발에 적합합니다. 2) V8 엔진을 예를 들어, 핵심은 C로 작성되며 C의 효율성 및 객체 지향적 특성을 결합하여 C로 작성됩니다.

JavaScript는 웹 페이지의 상호 작용과 역학을 향상시키기 때문에 현대 웹 사이트의 핵심입니다. 1) 페이지를 새로 고치지 않고 콘텐츠를 변경할 수 있습니다. 2) Domapi를 통해 웹 페이지 조작, 3) 애니메이션 및 드래그 앤 드롭과 같은 복잡한 대화식 효과를 지원합니다. 4) 성능 및 모범 사례를 최적화하여 사용자 경험을 향상시킵니다.

C 및 JavaScript는 WebAssembly를 통한 상호 운용성을 달성합니다. 1) C 코드는 WebAssembly 모듈로 컴파일되어 컴퓨팅 전력을 향상시키기 위해 JavaScript 환경에 도입됩니다. 2) 게임 개발에서 C는 물리 엔진 및 그래픽 렌더링을 처리하며 JavaScript는 게임 로직 및 사용자 인터페이스를 담당합니다.

JavaScript는 웹 사이트, 모바일 응용 프로그램, 데스크탑 응용 프로그램 및 서버 측 프로그래밍에서 널리 사용됩니다. 1) 웹 사이트 개발에서 JavaScript는 HTML 및 CSS와 함께 DOM을 운영하여 동적 효과를 달성하고 jQuery 및 React와 같은 프레임 워크를 지원합니다. 2) 반응 및 이온 성을 통해 JavaScript는 크로스 플랫폼 모바일 애플리케이션을 개발하는 데 사용됩니다. 3) 전자 프레임 워크를 사용하면 JavaScript가 데스크탑 애플리케이션을 구축 할 수 있습니다. 4) node.js는 JavaScript가 서버 측에서 실행되도록하고 동시 요청이 높은 높은 요청을 지원합니다.

Python은 데이터 과학 및 자동화에 더 적합한 반면 JavaScript는 프론트 엔드 및 풀 스택 개발에 더 적합합니다. 1. Python은 데이터 처리 및 모델링을 위해 Numpy 및 Pandas와 같은 라이브러리를 사용하여 데이터 과학 및 기계 학습에서 잘 수행됩니다. 2. 파이썬은 간결하고 자동화 및 스크립팅이 효율적입니다. 3. JavaScript는 프론트 엔드 개발에 없어서는 안될 것이며 동적 웹 페이지 및 단일 페이지 응용 프로그램을 구축하는 데 사용됩니다. 4. JavaScript는 Node.js를 통해 백엔드 개발에 역할을하며 전체 스택 개발을 지원합니다.

C와 C는 주로 통역사와 JIT 컴파일러를 구현하는 데 사용되는 JavaScript 엔진에서 중요한 역할을합니다. 1) C는 JavaScript 소스 코드를 구문 분석하고 추상 구문 트리를 생성하는 데 사용됩니다. 2) C는 바이트 코드 생성 및 실행을 담당합니다. 3) C는 JIT 컴파일러를 구현하고 런타임에 핫스팟 코드를 최적화하고 컴파일하며 JavaScript의 실행 효율을 크게 향상시킵니다.

실제 세계에서 JavaScript의 응용 프로그램에는 프론트 엔드 및 백엔드 개발이 포함됩니다. 1) DOM 운영 및 이벤트 처리와 관련된 TODO 목록 응용 프로그램을 구축하여 프론트 엔드 애플리케이션을 표시합니다. 2) Node.js를 통해 RESTFULAPI를 구축하고 Express를 통해 백엔드 응용 프로그램을 시연하십시오.

웹 개발에서 JavaScript의 주요 용도에는 클라이언트 상호 작용, 양식 검증 및 비동기 통신이 포함됩니다. 1) DOM 운영을 통한 동적 컨텐츠 업데이트 및 사용자 상호 작용; 2) 사용자가 사용자 경험을 향상시키기 위해 데이터를 제출하기 전에 클라이언트 확인이 수행됩니다. 3) 서버와의 진실한 통신은 Ajax 기술을 통해 달성됩니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기
