reading-notes

Class 06: JavaScript

Making Dynamic Pages with JavaScript



What is JavaScript?


What is JavaScript?
JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else.

Quote link

Who wrote it and when?

JavaScript was invented by Brendan Eich in 1995, and became an ECMA standard in 1997.

ECMA-262 is the official name of the standard. ECMAScript is the official name of the language.

Class notes

What can JS do?

External JavaScript Advantages

Placing scripts in external files has some advantages:

JavaScript Display Possibilities

JavaScript can “display” data in different ways:

JavaScript statements are composed of

Values, Operators, Expressions, Keywords, and Comments.

JS Keywords

JavaScript keywords are reserved words. Reserved words cannot be used as names for variables.

Keyword Descriptions
var Declares a variable
let Declares a block variable
const Declares a block constant
if Marks a block of statements to be executed on a condition
switch Marks a block of statements to be executed in different cases
for Marks a block of statements to be executed in a loop
function Declares a function
return Exits a function
try Implements error handling to a block of statements

How Computers Work- Playlist


JavaScript Guide

JavaScript Reference

Use Replit to play with JS


JavaScript Values

The JavaScript syntax defines two types of values:

  1. Fixed values are called Literals.
  2. Variable values are called Variables.

JavaScript Literals

The two most important syntax rules for fixed values are:

  1. Numbers are written with or without decimals
  2. Strings are text, written within double or single quotes

Variables

Variables are containers for storing data (storing data values).In a programming language, variables are used to store data values. JavaScript uses the keywords var, let and const to declare variables. An equal sign is used to assign values to variables.

4 ways to declare a JS Variable


JavaScript Let

Why is it important to use Let instead of the old var

JavaScript const

Use const when you declare

JavaScript Operators

Equal Signs =

JavaScript Expressions

An expression is a combination of values, variables, and operators, which computes to a value. The computation is called an evaluation.

JavaScript Comments

Not all JavaScript statements are “executed”. Code after double slashes // or between /and/ is treated as a comment. Comments are ignored, and will not be executed

JavaScript Identifiers

The general rules for constructing names for variables (unique identifiers) are:

Unicode

JavaScript uses the Unicode character set. Unicode covers (almost) all the characters, punctuations, and symbols in the world.

JavaScript Data Types

JavaScript has 8 Datatypes

  1. String
  2. Number
  3. Bigint
  4. Boolean
  5. Undefined
  6. Null
  7. Symbol
  8. Object

The Object Datatype

The object data type can contain:

  1. An object
  2. An array
  3. A date

You can declare many variables in one statement

Value = undefined

In computer programs, variables are often declared without a value. The value can be something that has to be calculated, or something that will be provided later, like user input. A variable declared without a value will have the value undefined.


Dynamic Components


Standard Objects

Object Define
Object fundamental language constructs
Function fundamental language constructs
Boolean fundamental language constructs
Symbol fundamental language constructs
Number base objects representing numbers, dates, and mathematical calculations
BigInt base objects representing numbers, dates, and mathematical calculations
Math base objects representing numbers, dates, and mathematical calculations
Date base objects representing numbers, dates, and mathematical calculations
String represent strings and support manipulating them
RegExp represent strings and support manipulating them


Answer

  1. What are variables in JavaScript?
    • Variables are objects that you can store information
  2. What does it mean to declare a variable?
    • Declaring means you are creating a variable for the first time
  3. What is an “assignment” operator, and what does it do?
    • Assignment operators assign values to JS variables using the equal sign ( = ) .
  4. What is information received from the user called?
    • When the user gives an answer ( by pressing okay/submit ) to our questions, it’s called “input value”. The user input is then stored in a variable to be used as information in our program.