Jargons?
Week 1.2
Javascript foundation
Why languages?
how does computer work- applications, photo video etc in short storage purpose- ssd
zoom call surfing internet- ram- currently running things. Ram reads and understands only 0s and 1s
not any source code. Fro souce code to 0s and 1s is converted by compilers. C++ Jaca python etc are
high level languages that we underatsnad then it is converted to 0s and 1s by compilers that the
machine can understand.
languages are used to write applications.
Compiler?
High level codes- 0s and 1s
C++ most famous compiler- g++ temp is a binary file, gta file?
you can share the temp file so other people can run your code.
Javascript is a interpreted language
[Link](“Hello world”)
(syntax to take input in javascript?)
it runs the code line by line, compiles the code
Compiled languages- first need to compile then need to run, usually don’t compile if there is and
error in the code, example: c++, java, rust, golang
Interpreted languages- usually go line by line, can run partially if the error comes later, Example-
Javascript, Python.
Note : Save files on vs code before running!
For 99.9% of websites, javascript is the primary language. Browsers can understand HTML/CSS/JS
mostly.
Static vs dynamic language:
Javascript can be used for backend using [Link]. It as a dynamic language (datatypes can be
changed midcode).
C++ is static (If datatypes are changed mid code the compile will throw error). (explain dynamic and
static language?)
Typescript- to make js more static
Single threaded language:
Number of corres mean 1 process can be running on 1 core and another on other cores. Java script
acquires 1 core of a machine at a time. It can’t distribute the load. This why it is considered to be bad
language for scalable systems. There is a way to make it use all cores of your machine somehow
(later). So single threaded means that the labguage uses 1 core of machine at a time
Simple primitives:
Variables (let, var, const)- let can change its value, const only for constant
data types(strings numbers booleans)
if/else
loops/ for loops
Arrays
objects- can be nested (Write syntax for both arrays and objects and array for objects)
Functions:
1. Abstract out logic in your program.
2. Take arguments as an input
3. Return a value as an output
4. You can think of them as an independent program that is supposed to do something given an
input.
5. Function can take other functions as input (callbacks)
Global function that js provides- setTimeout(function, duration)