📜 ⬆️ ⬇️

Prototypes of new JavaScript extensions

Current trends are such that the HTML5 platform is becoming more functional, web applications are becoming richer and scenarios that require interaction with the server side to perform trivial tasks are becoming increasingly tedious. If we look at the client code, we can notice some lack of JavaScript capabilities.

Microsoft is involved in improving the JavaScript standard. Through active participation in the Ecma TC39 working group, we agreed and sent for approval a ready-made part of the proposed standards, which offer the expansion of such important libraries as Math , Number and String and presented support for the new Globalization functionality. We talked about the first versions of library prototypes at a meeting on the standard in July on the Microsoft campus and told about the implementation of Globalization at the meeting of the standard group on the Apple campus in Cupertino last week. In addition, we released these base implementations so that the JavaScript community could provide feedback when using new features in practice.

What do we offer

In this release, we offer the following extensions for embedded JavaScript libraries:
')
image

In order to illustrate, we give the following code:

var aStr = "24-"; var aStrR = aStr.reverse(); var num = aStrR * 1; if (Number.isInteger(num)) { console.log("The sign of " + num + " is " + Math.sign(num)); }; 

In this release, we also included the implementation of the evolving Globalization specification. Globalization (globalization) is a concept in software development that implies the correct processing and support of working with numbers, formats, currencies and dates of different countries. Using this library, you can display dates and numbers in the required format and specify ordering properties for the purposes of organizing the correct sorting and searching in different languages ​​and formats of different countries. You can also set date and number formats for using alternative calendars in your code, such as the Islamic calendar or the correct currency display, such as the Chinese yuan. Below is the demo code:

 var nf = new Globalization.NumberFormat(localeList, { style : "currency", currency : "CNY", currencyDisplay: "symbol", maxmimumFractionDigit: 1 }) nf.format(100); // "¥100.00" var dtf = new Globalization.DateTimeFormat( new Globalization.LocaleList(["ar-SA-u-ca-islamic-nu-latin"]), { weekday : "long", }) dtf.format() // today's date dtf.format(new Date("11/15/2011")); // "الثلاثاء, ١٢ ١٩ ٣٢" 

How to get new functionality?

Library prototypes will be loaded automatically when you go to the Intrinsics Extensions demo or Globalization demo demo (demonstrations require Internet Explorer 9, because extensions are installed via the browser extension). Another way to download a library is to download directly from the Microsoft standards website. Keep in mind that, like other HTML5 Labs releases, these demonstration libraries are not covered by Microsoft. They should be used only for study and should not be used in industrial applications.

Your feedback

We have created several demo applications so that you can evaluate the new functionality. After you install the components, pay attention to the Intrinsics Extensions and Globalization demo in order to evaluate the new APIs in action (the demonstrations require Internet Explorer 9, since the extensions are installed via the browser extension).

As always, we encourage you to test libraries, study and try out examples, download prototypes, and develop your own demo applications as you like. We are trying to improve JavaScript and make building functional applications easier using standards.

Thank you for your interest!

Claudio Caldato, Adalberto Foresti - Interoperability Strategy Team.

Source: https://habr.com/ru/post/133278/


All Articles