We are going to share you some cool JavaScript features you will love them features like Base64 encoding and decoding, The vibration API, Constants, CSS property is supported with JavaScript and The page visibility API.
Base64 encoding and decoding
You can use the btoa function to encode in base64 an arbitrary string and the atob function to decode the string.
Here is how you can use them:
var string = "Hello World!"; var encoded = btoa(string); // "SGVsbG8gV29ybGQh" var decoded = atob(encoded) // "Hello World!"
The battery status API
The battery status API allows you to get information regarding the battery status of the device browsing your website. Here is how you can use it:
var battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery || navigator.msBattery if (battery) { // battery API supported }
With this battery variable, you can get the battery’s level and find out whether the device is currently charging or not. You can use battery.charging and battery.level to find those things out.