Getting Started with JavaScript

Tushar Rajpoot
3 min readFeb 3, 2021

After HTML and CSS we will go for JavaScript. Lets start development with JavaScript.

Introduction to JavaScript

What is Javascript?

  • JavaScript is a cient side scripting language.
  • It is used to make web pages alive.
  • It is used to programmatically perform actions within the page.
  • When JavaScript was created, it was initially called “LiveScript”.
  • But java was a very popular language at that time, so it was decided that positioning language as a “younger brother” of java would help.

What JavaScript can do?

  • JavaScript can execute not only in the browser, but also on the server.(Node js)
  • We will use JavaScript as a client as well as server side language.
  • JavaScript has envolved greatly as a language and is now used to perform wide variety of tasks.

What can in-browser JavaScript do?

  • Safety — — JavaScript don’t have low level permissions(executes through browser)
  • Add new HTML and change existing HTML from DOM(document object model)
  • React to events(actions that user performs)
  • Ajax Requests(send a request to the server)
  • Get and Set cookies(An HTTP cookie is a small piece of data stored on the user’s computer by the web browser while browsing a website.)

What can’t in-browser JavaScript do?

  • Read/write to/from computer hard disk without permission.

1. Introduction to console.log

2. Variables and operators in JavaScript

3. Strings in JavaScript

4. String functions in JavaScript

5. Scope- let, const, If-else conditionals and Switch case in JavaScript

6. Arrays and objects

7. Functions in JavaScript

8. Alert, prompt, confirm in JavaScript

Q. Ask the user age in your page and return on the console, he can drive or not.

9. Loops

For loop in JavaScript

for (let i = 0; i < array.length; i++) {
const element = array[i];

}

10. DOM Maniplulation

What is DOM?

The HTML DOM (Document Object Model) When a web page is loaded, the browser creates a Document Object Model of the page.

The HTML DOM model is constructed as a tree of Objects:

DOM HTML Tree

With the object model, JavaScript gets all the power it needs to create dynamic HTML:

JavaScript can change all the HTML elements in the page JavaScript can change all the HTML attributes in the page JavaScript can change all the CSS styles in the page JavaScript can remove existing HTML elements and attributes JavaScript can add new HTML elements and attributes JavaScript can react to all existing HTML events in the page JavaScript can create new HTML events in the page

11. Events and listening to events

JavaScript Events

HTML events are “things” that happen to HTML elements.
When JavaScript is used in HTML pages, JavaScript can “react” on these events.

HTML Events

An HTML event can be something the browser does, or something a user does.
Here are some examples of HTML events:

  • An HTML web page has finished loading
  • An HTML input field was changed
  • An HTML button was clicked

Often, when events happen, you may want to do something.
JavaScript lets you execute code when events are detected.
HTML allows event handler attributes, with JavaScript code, to be added to HTML elements.

element event='some JavaScript'

SetInterval and set timeout

Date and Time

Mini Project 1 — Make a digital clock.

Arrow Functions

Math Object in JavaScript

Working with JSON

What is JSON?

  • JSON stands for JavaScript Object Notation
  • JSON is a lightweight format for storing and transporting data
  • JSON is often used when data is sent from a server to a web page
  • JSON is “self-describing” and easy to understand
{
"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]
}

--

--