-
ECMAScript standards, it stands for the European Computer Manufacturers Association (ECMA). Which gives standards to JS.
-
Variables
Primitives are single self related like numbers, boolean, strings etc Compounds data are held as arrays objects
-
We use let and const to declare variables
-
Arrays
const arr = [1,2,3] console.log(arr[0])
- Objects (also known dictionaries in other languages)
const obj = {
name: "Siat",
email: "siat@ymail.com"
}
console.log(obj.name)
- It's the JS representation of the structure of HTML and is present in the variable document when we load the page
document
{} like querySelector()
element
{} {} {} like .addEventListener().style.color
- All this is possible with the set of methods called the Browser API
- Its a C like language, meaning it's most of the syntax came from C
- It contains if, while, for and more
- we use for in loop to iterate object example
const obj = {
name: "siat",
age: 26
}
for(let key in obj) {
console.log(key.obj[key]);
}
Sample Output: 'name' 'siat' 'age' 26
- we use for of to iterate array
let nums = [1,2,3,4]
for(let num of nums) {
console.log(num)
}
Sample output: 1 2 3 4
- we declare functions by special keyword function after that name add and inside that we need to put the parameter
function add (first, second){
return first+second;
}
add(1,2) // declare the function or use the function
// here 1 2 are the arguments
- methods are same as functions
- that they are attached to different data types
"hi" .toUpperCase() // HI
['c', 'b', 'a'] .sort() // ['a', 'b', 'c']
[1,2,3] .indefOf(1) // 0
- we can say it's like performing non-deterministic operation
- Some important parts
- Network Request to server
fetch(http:://server)
- Callbacks, promises
- Network Request to server
- It compiles into normal javascript
- It gives static variable
- we need to mention variable type in TS
- Node Package Manager
- We can use various packages with npm