1582077931
We have been using various techniques and logics for formatting numbers, currencies and dates. Once one uses the tolocalestring() he or she is definitely not going back. After doing some research online we are surprised to see how few people are actually using this in their web apps despite its simplicity and easy implementation.
“toLocaleString()” is a method that returns a string with a language sensitive representation of number or date. Basically in the case of numbers it returns a string of numbers with comma separators and in the case of the date, it formats it in ‘dd-mm-yyyy’ or ‘mm-dd-yyyy’ depending on the language and locales one specifies in the parameter of the method.
In this article, we are about to explore the use of toLocaleString() to format numbers, dates, and currencies.
Below is a basic implementation of this method to localize the number.
var initNumber = 123456789.456789;
initNumber.toLocaleString();
//console output > "123,456,789.457"
The method toLocaleString() mainly takes 2 arguments.
.toLocaleString([locales][,options])
It’s an optional parameter in the string which holds a BCP 47 language tag or an array of such tags. By default, it uses “default” locale.
A BCP 47 language tag defines a language and minimally contains a primary language code. In its most common form, it can contain, in order: a language code, a script code, and a country or region code, all separated by hyphens.
Note
The tag is not case sensitive but it is recommended to use title case for script code, upper case for country and a small case for everything else.
Example
“hi” : Hindi (primary language)
“en-IN” : English (primary language) and India(country)
“hi-Deva-IN” : Hindi (primary language), Devanagari(script) and India(country)
Formatting Number
var InitFraction= 123456789.456789;
InitFraction.toLocaleString('en-IN', {
minimumFractionDigits: 0,
maximumFractionDigits: 0
});
//console output > "12,34,56,789"
InitFraction.toLocaleString('en-IN', {
minimumFractionDigits: 2,
maximumFractionDigits: 3
});
//console output > 12,34,56,789.457
InitFraction.toLocaleString('en-IN', {
minimumFractionDigits: 3,
maximumFractionDigits: 9
});
//console output > 12,34,56,789.456789
// options
//maximumFractionDigits -> The maximum number of fraction digits to use.
//maximumFractionDigits -> The minimum number of fraction digits to use.
Formatting Currencies
var InitNumber = 50000000;
var InitFraction = 123456789.456789;
InitNumber.toLocaleString('en-IN', {
style: 'currency',
currency: 'INR',
currencyDisplay: 'symbol'
});
//console output > "₹ 12,34,56,789.46"
InitNumber.toLocaleString('en-US', {
style: 'currency',
currency: 'USD',
currencyDisplay: 'code'
});
//console output > "USD 123,456,789.46"
InitFraction.toLocaleString('az-AE', {
style: 'currency',
currency: 'AED',
currencyDisplay: 'code',
maximumFractionDigits: 5,
minimumFractionDigits: 2
});
//console output > "AED 123,456,789.45679"
// options
//style -> The formatting style to use. Possible values are "decimal" for plain number
// formatting, "currency" for currency formatting, and "percent" for percent formatting; // the default is "decimal".
//currency -> The currency to use in currency formatting. Possible values are the ISO 4217
// currency codes, such as "USD" for the US dollar, "EUR" for the euro, or "INR" for
// Indian Rupee.
//currencyDisplay -> How to display the currency in currency formatting. Possible values are
// "symbol" to use a localized currency symbol such as €, "code" to use the
// ISO currency code, "name" to use a localized currency name such as
// "dollar"; the default is "symbol".
//maximumFractionDigits -> The maximum number of fraction digits to use.
//maximumFractionDigits -> The minimum number of fraction digits to use.
Formatting Date
var InitDate = new Date();
InitDate.toLocaleString('en-IN', {
timeZone: 'Asia/Kolkata',
hour12: true
});
//console output > "24/5/2019, 9:01:30 PM"
InitDate.toLocaleString('en-US', {
timeZone: 'America/New_York',
hour12: false
});
//console output > "5/24/2019, 11:31:30"
InitDate.toLocaleString('en-AE', {
timeZone: 'Asia/Dubai',
hour12: true
});
//console output > "5/24/2019, 7:31:30 PM"
//options
//timeZone -> The time zone to use. The only value implementations must recognize is "UTC"; the
// default is the runtime's default time zone.
//hour12 -> Whether to use 12-hour time (as opposed to 24-hour time). Possible values are true and
// false; the default is locale dependent.
Thank you for reading!
#javascript #tutorial #toLocaleString #developer
1606912089
#how to build a simple calculator in javascript #how to create simple calculator using javascript #javascript calculator tutorial #javascript birthday calculator #calculator using javascript and html
1622207074
Who invented JavaScript, how it works, as we have given information about Programming language in our previous article ( What is PHP ), but today we will talk about what is JavaScript, why JavaScript is used The Answers to all such questions and much other information about JavaScript, you are going to get here today. Hope this information will work for you.
JavaScript language was invented by Brendan Eich in 1995. JavaScript is inspired by Java Programming Language. The first name of JavaScript was Mocha which was named by Marc Andreessen, Marc Andreessen is the founder of Netscape and in the same year Mocha was renamed LiveScript, and later in December 1995, it was renamed JavaScript which is still in trend.
JavaScript is a client-side scripting language used with HTML (Hypertext Markup Language). JavaScript is an Interpreted / Oriented language called JS in programming language JavaScript code can be run on any normal web browser. To run the code of JavaScript, we have to enable JavaScript of Web Browser. But some web browsers already have JavaScript enabled.
Today almost all websites are using it as web technology, mind is that there is maximum scope in JavaScript in the coming time, so if you want to become a programmer, then you can be very beneficial to learn JavaScript.
In JavaScript, ‘document.write‘ is used to represent a string on a browser.
<script type="text/javascript">
document.write("Hello World!");
</script>
<script type="text/javascript">
//single line comment
/* document.write("Hello"); */
</script>
#javascript #javascript code #javascript hello world #what is javascript #who invented javascript
1616670795
It is said that a digital resource a business has must be interactive in nature, so the website or the business app should be interactive. How do you make the app interactive? With the use of JavaScript.
Does your business need an interactive website or app?
Hire Dedicated JavaScript Developer from WebClues Infotech as the developer we offer is highly skilled and expert in what they do. Our developers are collaborative in nature and work with complete transparency with the customers.
The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.
Get your business app with JavaScript
For more inquiry click here https://bit.ly/31eZyDZ
Book Free Interview: https://bit.ly/3dDShFg
#hire dedicated javascript developers #hire javascript developers #top javascript developers for hire #hire javascript developer #hire a freelancer for javascript developer #hire the best javascript developers
1620729846
Can you use WordPress for anything other than blogging? To your surprise, yes. WordPress is more than just a blogging tool, and it has helped thousands of websites and web applications to thrive. The use of WordPress powers around 40% of online projects, and today in our blog, we would visit some amazing uses of WordPress other than blogging.
What Is The Use Of WordPress?
WordPress is the most popular website platform in the world. It is the first choice of businesses that want to set a feature-rich and dynamic Content Management System. So, if you ask what WordPress is used for, the answer is – everything. It is a super-flexible, feature-rich and secure platform that offers everything to build unique websites and applications. Let’s start knowing them:
1. Multiple Websites Under A Single Installation
WordPress Multisite allows you to develop multiple sites from a single WordPress installation. You can download WordPress and start building websites you want to launch under a single server. Literally speaking, you can handle hundreds of sites from one single dashboard, which now needs applause.
It is a highly efficient platform that allows you to easily run several websites under the same login credentials. One of the best things about WordPress is the themes it has to offer. You can simply download them and plugin for various sites and save space on sites without losing their speed.
2. WordPress Social Network
WordPress can be used for high-end projects such as Social Media Network. If you don’t have the money and patience to hire a coder and invest months in building a feature-rich social media site, go for WordPress. It is one of the most amazing uses of WordPress. Its stunning CMS is unbeatable. And you can build sites as good as Facebook or Reddit etc. It can just make the process a lot easier.
To set up a social media network, you would have to download a WordPress Plugin called BuddyPress. It would allow you to connect a community page with ease and would provide all the necessary features of a community or social media. It has direct messaging, activity stream, user groups, extended profiles, and so much more. You just have to download and configure it.
If BuddyPress doesn’t meet all your needs, don’t give up on your dreams. You can try out WP Symposium or PeepSo. There are also several themes you can use to build a social network.
3. Create A Forum For Your Brand’s Community
Communities are very important for your business. They help you stay in constant connection with your users and consumers. And allow you to turn them into a loyal customer base. Meanwhile, there are many good technologies that can be used for building a community page – the good old WordPress is still the best.
It is the best community development technology. If you want to build your online community, you need to consider all the amazing features you get with WordPress. Plugins such as BB Press is an open-source, template-driven PHP/ MySQL forum software. It is very simple and doesn’t hamper the experience of the website.
Other tools such as wpFoRo and Asgaros Forum are equally good for creating a community blog. They are lightweight tools that are easy to manage and integrate with your WordPress site easily. However, there is only one tiny problem; you need to have some technical knowledge to build a WordPress Community blog page.
4. Shortcodes
Since we gave you a problem in the previous section, we would also give you a perfect solution for it. You might not know to code, but you have shortcodes. Shortcodes help you execute functions without having to code. It is an easy way to build an amazing website, add new features, customize plugins easily. They are short lines of code, and rather than memorizing multiple lines; you can have zero technical knowledge and start building a feature-rich website or application.
There are also plugins like Shortcoder, Shortcodes Ultimate, and the Basics available on WordPress that can be used, and you would not even have to remember the shortcodes.
5. Build Online Stores
If you still think about why to use WordPress, use it to build an online store. You can start selling your goods online and start selling. It is an affordable technology that helps you build a feature-rich eCommerce store with WordPress.
WooCommerce is an extension of WordPress and is one of the most used eCommerce solutions. WooCommerce holds a 28% share of the global market and is one of the best ways to set up an online store. It allows you to build user-friendly and professional online stores and has thousands of free and paid extensions. Moreover as an open-source platform, and you don’t have to pay for the license.
Apart from WooCommerce, there are Easy Digital Downloads, iThemes Exchange, Shopify eCommerce plugin, and so much more available.
6. Security Features
WordPress takes security very seriously. It offers tons of external solutions that help you in safeguarding your WordPress site. While there is no way to ensure 100% security, it provides regular updates with security patches and provides several plugins to help with backups, two-factor authorization, and more.
By choosing hosting providers like WP Engine, you can improve the security of the website. It helps in threat detection, manage patching and updates, and internal security audits for the customers, and so much more.
#use of wordpress #use wordpress for business website #use wordpress for website #what is use of wordpress #why use wordpress #why use wordpress to build a website
1589255577
As a JavaScript developer of any level, you need to understand its foundational concepts and some of the new ideas that help us developing code. In this article, we are going to review 16 basic concepts. So without further ado, let’s get to it.
#javascript-interview #javascript-development #javascript-fundamental #javascript #javascript-tips