Basic of JavaScript
In ES6 JavaScript has 6 types of Data:
Number, String, Boolean, Function, Object, Symbol
Number:
JavaScript Numbers are Always 64-bit Floating Point. We can convert a string to an integer using the built-in parseInt() function.
Similarly we can parse floating point numbers using the built-in parseFloat() function.
A special value is called NaN is returned if the string is non-numerical. We can test NaN using the built-in Number.isNaN() function.
JavaScript also has the special values Infinity. They are 0 and 1.
Strings:
JavaScript strings are sequences of Unicode characters. Each Unicode character is represented by either 1 or 2 code units.
To find the length of strings, length property is used.
slice() = This method extracts a section of a string and returns it as a new string. Example:
split() = This method divides a string into an ordered list of substrings, puts these substrings into an array, and returns the array. Example:
Boolean:
Boolean types has two possible values, true and false.
False: False, 0, empty strings (“”), NaN, null, and undefined all become false
True: All other values become true
Function:
A function definition consists of the function keyword.
Object:
The object class represents one of the JavaScript data types. It is used to store various keyed collections and more complex entities.
Symbol:
Every symboll() call is guaranteed to return a unique Symbol. Every symbol.for(“key”) call will always return the same Symbol for a given value of "key”. When symbol.for(“key”) is called, if a Symbol with the given key can be found in the global Symbol registry, that Symbol is returned. Otherwise, a new Symbol is created, added to the global Symbol registry under the given key, and returned.
— — — — — — — — — — — — — — — — — — — — — — — — — —
Math:
Math.max() = This function returns the largest number from the input number. Example:
Math.min() = This function returns the lowest number from the input number. Example:
Math.random() = This function returns the random number from the input number. Example:
Array
every() = This method tests all elements in the array pass the test implemented by the provided functions. It return the Boolean value. Example:
find() = Return the first element in the provided array that satisfies the provided testing function. Example:
forEach() = It provide all array element once. Example: