Basic of Javascript

Basic of Javascript

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

  1. Number - integer, float.

  2. String - Any data under single quote, double quote, or backtick quoted - string is a collection of characters.

  3. Booleans - true or false value.

  4. Null - empty value or no value.

  5. Undefined - a declared variable without a value.

  6. 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.

  1. Arithmetic Operators

  2. Assignment Operators

  3. comparison operators

  4. logical operators

  5. Bitwise Operators

  6. conditional operators

  7. comma operators

conditionals in javascript

  1. “If” statements: where if a condition is true it is used to specify execution for a block of code.

  2. “Else” statements: where if the same condition is false it specifies the execution for a block of code.

  3. “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.

  1. false,

  2. 0,

  3. an empty string (''),

  4. null,

  5. undefined,

  6. 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

  1. push - adds new items to the end of an array

  2. pop - removes (pops) the last element of an array

  3. swift - remove 1st(0th index) element and return it, change of array

  4. unshift - adds new elements to the beginning of an array.

  5. join - not change og array, convert the array into a string (_, - , : )

  6. concat() - merge to or more arrays not modify of the array, return a shallow copy

  7. length of the array

  8. reverse() => reverse the actual array and return it

  9. toString()

  10. includes

  11. flat - merge of any selected array