# JS review
Js fundamentals part 1
-
what is js .high level language- dont have to think complex detail its easy to use and to understand .object oriented- based on objects storing most kind of data .multi paradigm- versatile we can use differnt styles of programming
-
node js- can run js with out using browser called runtime enviroment
-
js releases the old JS ----> ES5 modern JS starts from JS ES6---> ES14
-
ES means ECMA Script ECMA is a standard for scripting language
-
values and variables value with out declaring a variable
.varibale names cant start with numbers let 4month X .symbols arent allowed either except $ and _ .dont start varibales in capital letter not illegal but... .varaibales must make meaning dont just give random name easy to read
-
data type
two type of values- object
- primitive value
primitive value
-
numbers- include decimal integer float its same for all
-
string -for characters
-
boolean- true or false
-
undefined- not yet defined let childern;
-
null- empty
-
symbol(ES2015)- unique and cant be changed
-
bigint(ES2020)-large integers than the number type can hold
js has dynamic typing-- we dont have to manually define data type instead it is stored automatically
-
declaring variables
let const and var
var is the oldest in ES6
let have similarities with var let can change values after assigning them and we can unidentify the value of the varibale
const is the opp of let cant change values and can assign unknown value for variable.
-
math operators
"* **" Exponent < > <= >= * / - + %
-
operator precedence- important operator find on MDN
-
string and template literals we use template literals to connect strings
${vaiable}
\n new line \n\ multiple line
-
if else statement
-
type conversion and type coercion
type coercion is when the js automatically conversts the type( hidden from as) type conversion is when we change the type manually
-
truthy and falsy
falsy values 0, '', undefined,null,NaN
- equality operator
=== strict equlity type coercison cant occur == loose equality type coercion can happen int and str might be equal
-
prompt to input value we can add Number or String to specify the input value
-
boolean logic and, or, not && and || or ! not
-
switch statement switch and case statement this has same function as if else
-
statement and expressions
expression is code can express value statement is cant express value and template literal insert exprssion not statements
- the conditional(ternary) operator same us if and switch but less lines we can use it in template literal
Js fundamentals part 2
-
activating strict mode
will treat errors more strictly
-
functions 1.declaration 2.expression 3.arrow(Concise Body Arrow Functions) -----Functions that take only a single parameter do not need that parameter to be enclosed in parentheses. However, if a function takes zero or multiple parameters, parentheses are required. ------A function body composed of a single-line block does not need curly braces. Without the curly braces, whatever that line evaluates will be automatically returned. The contents of the block should immediately follow the arrow => and the return keyword can be removed. This is referred to as implicit return.
-
scope Scope defines where variables can be accessed or referenced. While some variables can be accessed from anywhere within a program, other variables may only be available in a specific context.
-
arrays push unshift ,,, pop shift
-
objects
assigning value for arrays of data similar to array
any funtion that is attached to a object is called Method
"this" keyword in javascript refers to an object when we are using it in method
- Break and continue
The break statement "jumps out" of a loop.
The continue statement "jumps over" one iteration in the loop.
-
loop backward i-- forward i++
-
while loop
devloper skills
-
prettier
-
vs snippet
-
debugging
-
using extensions
-
using console and breaking points
-
JS runtime such as node js
-
using stackoverflow and mdn
what is DOM and what is DOM manipulation?
16.the DOM is used to represent a web page as a tree of objects. Each node in the tree represents an element on the page, such as a heading, a paragraph, or an image. You can use the DOM to manipulate the page's content, style, and behavior.
adding event listeners dom manipulations
DRY-----dont repeat your self principle
refactoring is to fix duplicated codes