tgoop.com/Web_developerszz/227
Last Update:
Top 7 useful JavaScript concepts that every developer should know
1. classList
It's a JavaScript property to work with classes in HTML, rather than using setAttribute to class it decreases code readability, in clssList, we have different properties like, a) add, b) remove, c) toggle d) contains and many more. classList is an easy an efficient way to work with classes for html elements.
2. insertAddacentHTML
This is JS DOM property, which is used to insert HTML in a HTML page via JavaScript, rather creating elements with .createEelement(), it makes the flow easy and efficient to work with creating HTML elements.
3. IIFE - Immediately invoked function expression
As the name suggests, IIFE functions are invoked (called) immediately as soon as they are defined. These functions are helpful when you want to invoke a function without any condition. IIFE function follows Block-scope scoping, so variables declared in the function can not be used outside of the function.
4. Optional chaining [?.]
Optional chaining is a safe way to access properties of a nested object or call a function. If the object or called function is null or undefined, it will always return undefined instead of throwing an error.
5. Logical AND [&&]
It's boolean operator which returns true only if both conditions are true, else it will return false. This operator can also be used when you want to perform a operation, based on only if the condition is either true or false. It saves storage space and increases code readability.
6. Condtional (ternary) operator [?:]
This operator is used when you want to overcome the use of so many if-else statement in your code. It's followed by 3 operands:
(condition) ? true : false
7. Plus (+)
By adding as prefix for any string number will change the datatype to number
Join @Web_developerszz for more
BY Web Developer
Share with your friend now:
tgoop.com/Web_developerszz/227