Skip to main content

Posts

Showing posts from April, 2020

Unknown Facts about JavaScript

Along with HTML, CSS; JavaSript is one of the three main things of the www. Today I will be discussing a few facts, which might help you respect JavaScript even more. Even for developers that interact with it daily, some part of the language remains unexplored. I myself was surprised as I had no idea about maximum of the facts I am going to discuss now. 1. Presumably, JavaScript has 2 sets of Zeros.: -0 and +0. Although both of them are considered to be equal. This so happens because both (-0).toString() and (+0).toString() results to 0. And hence the console shows both -0 and +0 as simply 0. 1 2 3 4 +0 → 0 -0 → 0 2. The XOR(^) is used in cryptography. 1 2 3 4 5 6 7 8 9 10 11 // Alice and Bob share the same secr et key: let key = 123; // Alice wants to send Bob a number let msg = 42; // But before sending it, Alice encrypts it: msg = msg ^ key // or directly: msg ^= key → 81 // Bob receives 45, but knowing