Persist data using Local Storage and Angular
First Class JS | Modern Javascript from A to Z
by Viktor Borisov
4y ago
Intro Local storage and Session storage are part of the so called Web storage. Both of them give us the possibility to store key-value data on client side. The data stored in local storage is deleted only when the user clear his cache or we decide to clear the storage. The less used session storage is cleared immediately when the web browser tab is closed. As a more often used storage, we will explore the local storage, his functionalities and how to use it in the context of Angular. Use cases You may be thinking now, when we could take advantage of this storage and why we need it – why we don ..read more
Visit website
How to convert string to number in JavaScript (BE CAREFUL!)
First Class JS | Modern Javascript from A to Z
by Viktor Borisov
5y ago
Converting string to number in JavaScript is easily achievable using some of the built in methods. I’m saying “some”, because there are quite a few ways to achieve this. However, it could be a little confusing due to the fact that some of them will return a different result than the others. Here are the most popular methods to transform string to number using vanilla JavaScript: Number Probably the best method to convert string to number is the Number() function. This method works for both integer and decimal numbers. An important thing to mention here – if the value(the string ..read more
Visit website
Check if Object is empty in Javascript
First Class JS | Modern Javascript from A to Z
by Viktor Borisov
5y ago
Unfortunately, there is no build-in isEmpty or similar method to checking if specific object is empty(has own properties) in JavaScript. We usually create our own helper method or use an external library like lodash. Although, these libraries are offering a lot of goodies, it is highly impractical to import them just for using one or two methods(like buying a Ferrari to drive to the supermarket). My favorite way to check if a specific object is empty is using the Object.getOwnPropertyNames method.This method returns an array with all own properties of a specific object. We can use this ..read more
Visit website
Under The Hood: Arrays in JS
First Class JS | Modern Javascript from A to Z
by Martin Capodici
5y ago
Here are two truths about JavaScript: JavaScript does’t have integers, so you have to use numbers instead. JavaScript arrays are not typed, you can put whatever you want in them. Sounds reasonable? Well while these are true, and JavaScript’s semantics will honour these, the truth gets a bit more fuzzy as you delve into the details of what happens behind the scenes in the JavaScript engine. The Google V8 engine is used in the Chrome browser and Node programming environment. This engine will make optimisations based on the runtime behaviour of your program. This means the values in your number ..read more
Visit website

Follow First Class JS | Modern Javascript from A to Z on FeedSpot

Continue with Google
Continue with Apple
OR