Posts with the tag javascript:

Useful npm Packages for All Projects

date-fns date-fns (a.k.a Date Functions) is a library which gives you functions to deal with dates. It is great package with a small size. dotenv dotenv create a .env file to store your environment variables. So when you publish that project online you use the environment variables which you deploy the project on. Help you use the sockets to create realtime communications such as chat apps. UUID Help you create a universal unique identifier (UUID) with one line of code. axios Axios is an alternative to fetch. Axios help you make requests easier than fetch and AJAX. classnames Help you with class names in CSS with Javascript manipulations.

All Javascript Optimization Tips & Techniques

Parsing Objects in Javascript if you are using object like this. const data = {foo: 42, bar: 1337, ... }; use the JSON.parse() instead const data = JSON.parse('{"foo":42,"bar":1337, ... }'); It seems slower, but in the real world IT IS WAY WAY FASTER. Why is it faster? because JSON.parse() has one token (Javascript object literal), but the string literal has too many tokens. want to know more ? watch this video from Google chrome developers YouTube channel. If you want the benchmark results, see it here. Use requestAnimationFrame for visual changes When visual changes are happening on screen you want to do your work at the right time for the browser, which is right at the start of the frame.

Javascript Cheatsheet – Documentation and Code Snippets

Javascript is a scripting language, created to run in the Internet browser but later used in all places!. Javascript is always shortened as js or JS. Javascript Syntax: Variables // declare a variable var ourName; // store values myNumber = 5; myString = "myVar"; // declare variables with the assignment operator var myNum = 0; // add, subtract, multiply and divide numbers myVar = 5 + 10; // 15 myVar = 12 - 6; // 6 myVar = 13 * 13; // 169 myVar = 16 / 2; // 8 // increment and decrement numbers i++; // the equivalent of i = i + 1 i--; // the equivalent of i = i - 1; // decimals var ourDecimal = 5.