Posts

Showing posts from August, 2019

Javascript detect connection speed

Image
JavaScript detect connection speed Ever feel like your internet is running slow? Webpages seem sluggish while uploads and downloads take forever! It's very frustrating, especially when you pay for high-speed internet. As a developer, we need to find the current speed and load the pages accordingly. So if you want to get the connection speed in JS you can use the  Navigator.connection  object. Let's take an example: navigator.connection.addEventListener( 'change' , () => { let currRtt = navigator.connection.rtt; let effType = navigator.connection.effectiveType; console.log( 'current connections' , currRtt, effType) }) so the above example will trigger an event whenever there will be some changes in the network. So let's test it by changing the network connections. As you can see in logs whenever I changed the network type from network tab events gets fired and it printed the current connections types. Javascript detect...

Remove property from Javascript Object

Image
How to remove property from a JavaScript object If you want to remove property from a JavaScript object then you can do by following ways. Remove JavaScript Object Property lets create one object so we can run and test it. var user = { "id": "1001", "name": "Vikas", "email": "test@test.com", "password": "TesTP2ss", "createdAt": "20-08-2019" }; The  will be as follows: Now we can remove the object property from the following ways: Using delete operator: as we have seen the user's object now before sending to frontend we will delete the password property and then we will send it. delete user.password; >>true Or alternatively, you can do the following way as well. delete user['password']; >>true If delete won't work then you can use the following: user . password = undefined ; Please le...