Introduction to Javascript
Beginners’ guide
What is Javascript?
Javascript is a versatile language used for coding in multiple environments. Javascript
can run on almost any machine. You can run javascript on the browser, you can run it on
web servers, it also runs on smart devices, mobile phones (used for building mobile
applications), it can also run on wearables, i.e. smart watches etc.
If it runs code, it can run javascript!
Our Focus
Javascript is ubiquitous and versatile. Our focus for this lesson will be to understand
javascript basics and be able to read and write simple syntax.
The Syntax
Code is all about syntax (and semantics). The syntax for javascript that runs on any
machine is the same!
This difference lies in the APIs (Application Programming Interface) that is available on
each environment. More on that later.
First, let’s look at general Javascript syntax.
The Syntax (cond.)
Variables
Javascript like any other language has things known as variables. A variable is
something that holds a value in memory.
The examples below show two variables. first_name, last_name
let first_name = "Maryann"
let last_name = "Davies"
The ‘let’ is called a keyword. It is what tells Javascript that you want to define a
variable.
The Syntax (contd.)
A short snippet
let first_name = "Maryann"
let last_name = "Davies"
If (first_name == 'Maryann') {
[Link]("Happy to see you!")
} else {
[Link]("Welcome !")
}
More code samples
More code samples
What is [Link]?
[Link] is a runtime, it basically allows us run Javascript code on the server.
It is written in C++.
It runs on the v8 javascript engine.
Allows us use javascript as a server side language.
Concepts to know
- HTTP Requests (Status codes, headers etc.)
- JSON (Javascript Object Notation)
- Arrow functions (and function scopes)
- Promises
- MVC pattern
Why go with [Link]
- [Link] is very popular in the industry, used by a lot of startups
- [Link] is fast and scalable
- With [Link] you use the same language on the frontend and backend. Hence, it’s a
good skill for someone looking to go full-stack.
- [Link] is non-blocking and is single threaded.
What Non-Blocking means
Other backend languages like PHP that run synchronously. Which means it waits for one
process to end before running another.
With [Link] processes run asynchronously, which means one process does not need to
complete before another starts to run. This uses a background system known as the event
loop.
Popular Startups That Use [Link]
- Netflix
- Uber
- Linkedin
- Mozilla
- Ebay
How To Install [Link]
Steps
- Visit[Link]
- The website automatically detects your operating system and provides you with
down options. “LTS” or “Current”. You can download the “LTS”. Both are fine
though.
- Run the installer package on your computer to install node.
What the Node website looks like
Verifying your installation
To verify your installation is good run the command below in your terminal and you should see the expected
response with the version of your installation.
Brief About What a Terminal is
A terminal is an environment on your computer where you directly run commands for
the computer to do things you can or cannot achieve by using the normal user interface.
On mac, the default terminal is called “Terminal”.
On Linux, the default terminal is also called “Terminal”.
On windows, the default terminal is the “command prompt”, you can also use the
windows “powershell”.