what is js
JavaScript is a text-based programming language you can use from server side and client-side.
syntax of js
<script ...>
JavaScript code
</script>
Data type in Javascript
Number - integer, float.
String - Any data under single quote, double quote, or backtick quoted - string is a collection of characters.
Booleans - true or false value.
Null - empty value or no value.
Undefined - a declared variable without a value.
symbol - A unique value that can be generated by the Symbol constructor.
Operators in Javascript
Let us take a simple expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and ‘+’ is called the operator.
Arithmetic Operators
Assignment Operators
comparison operators
logical operators
Bitwise Operators
conditional operators
comma operators
conditionals in javascript
“If” statements: where if a condition is true it is used to specify execution for a block of code.
“Else” statements: where if the same condition is false it specifies the execution for a block of code.
“Else if” statements: this specifies a new test if the first condition is false.
False values in JavaScript
falsy values in JavaScript are values that are considered false when used in a Boolean context.
false,
0,
an empty string (''),
null,
undefined,
NaN (Not-a-Number).
Array in js
the array is an object is js that is capable of storing a collection of multiple items
it can be the same data type or a different data type
resizable
JavaScript arrays are not associative arrays
1st elm index 0, last index length-1
array copy operation performs a shallow copy
methods of Array
push - adds new items to the end of an array
pop - removes (pops) the last element of an array
swift - remove 1st(0th index) element and return it, change of array
unshift - adds new elements to the beginning of an array.
join - not change og array, convert the array into a string (_, - , : )
concat() - merge to or more arrays not modify of the array, return a shallow copy
length of the array
reverse() => reverse the actual array and return it
toString()
includes
flat - merge of any selected array