Use Math.PI To Calculate Area And Circumference Of A Circle
The "Math.PI" property returns the PI "π" constant, approximately equal to 3.14159. For example, you can calculate the circumference and surface area of a circle using "Math.PI".
Check If A Function Exists Before Calling With The typeof Operator
If you are sharing scripts from different modules or you have a large codebase, you can use the `typeof` operator to check if a function exists.
The "toggle()" is a method of the "DOMTokenList". It removes something like a "class" name from the list, and returns "false". If the "class" name does not exist, it will add it to the list and return "true".
A comparison operator compares two values with each other, and returns a logical value such as "true" or "false". The operands can be "number", "string", "logical", or "object" values.
The fillRect() method renders 2d context on HTML "canvas" element. You can create simple or complex shapes by defining ( x, y, width, height) on the canvas.
The Math.floot() function Rounds a number down to its closest integer, for example, Math.floor(5.99) returns 5.
You can shorten a string and limit the character length of a sentence using the slice(), substr() And substring() methods.
Learn how to flatten nested arrays with all the elements concatinated using the flat() method.