Geschrieben von Student*innen, die bestanden haben Sofort verfügbar nach Zahlung Online lesen oder als PDF Falsches Dokument? Kostenlos tauschen 4,6 TrustPilot
logo-home
Notizen

Modern Javascript - Essentials

Bewertung
-
Verkauft
-
seiten
84
Hochgeladen auf
01-05-2024
geschrieben in
2020/2021

Online course notes on JavaScript

Hochschule
Kurs

Inhaltsvorschau

JAVASCRIPT ESSENTIALS

Dynamic typing: variables in JS are not directly associated with any particular value types
and any variable can be assigned (re-assigned) values of all types:



PRIMITIVE DATA TYPES
1 - undefined
2 - null - primitive value (typeof object)
3 - booleans
4 - symbols
5 - numbers
6 - strings

To check the type of data type = typeof

Ex: typeof 87 → number
typeof “87” → string



1. UNDEFINED
A variable that has not been assigned a value has the value of undefined.


2. NULL
The null type has one value: null. null value represents a reference that points, generally
intentionally, to a nonexistent or invalid object or address.

● Intentional absence to any value
let loggedInUser = null

● Must be assigned



3. BOOLEANS
Boolean represents a logical entity and can have two values: true and false. The words true
and false are special keywords in JS, and don't need quotes.



4. SYMBOLS
A Symbol is a unique and immutable primitive value and may be used as the key of an
Object property.

, Modern Javascript Bootcamp 2020



5. NUMBERS
A Number. Numbers don't have quotes around them.

To note:
● Unary notation = it increments or subtracts the value by 1.

○ ex: let myNum = 5;
myNum++;
myNum = 6

● NaN = Not a Number is considered a number data type.




MATH OBJECT
Contains properties and methods for mathematical constants and functions.

● To access the Math Object, we need to type in Math - with uppercase M
○ Math.floor(3.6951) //3 - decimal point gets chopped
○ Math.round(4.6) //5
Math.round(4.4) //4
● Math.pow(7,2) //49 - raise the first arg to the power
of the sec arg
● Math.random() - generate a random decimal between 0
and 1 but 1 is not included. If we need 10, we need to transform the number
in different ways:
○ Generate a random integer:
const step1 = Math.random(); //0.5464861654;
const step2 = step1 * 10; //5.464861654;
const step3 = Math.floor(step2) //5
const step4 = step3 + 1; //6

Math.floor(Math.random() * 10) + 1;


parseInt() & parse Float()
Use to parse strings into numbers:

● parseInt(“24”); //24 returns an integer
parseFloat(“24.544”) //24.544 returns a float number



6. STRINGS
A sequence of text known as a string. Must be enclosed it in quote marks.



2

, Modern Javascript Bootcamp 2020


Strings in JS are immutable, meaning that the individual value is not changeable.


● CONCATENATION
let firstName = “Ilaria”;
let surname = “Callegari”

fullName = firstName + surname;
Fullname = “Ilaria Callegari”

● STRINGS ARE INDEXED
Chicken
0123456

● STRINGS HAVE A LENGTH
.length → called dot syntax → used to access a property
“chicken”.length = 7;

● TO ACCESS A CHARACTER OF THE STRING
ex: let animal = “chicken”
animal[0] = “c”



STRING METHODS

Without arguments
Methods are built-in pieces of functionality - an action that can be performed in a particular
value.
ex: syntax - thing.methodName()

● let msg = “you are so grounded mr”

msg.toUpperCase()
// “YOU ARE SO GROUNDED MR”

● let msg = “YOU ARE SO GROUNDED MR”

msg.toLowerCase()
// “you are so grounded mr”

● let greeting = “ leave me alone plz ”

greeting.trim()
//”leave me alone plz”

greeting.trim().toUpperCase()


3

, Modern Javascript Bootcamp 2020


//”LEAVE ME ALONE PLEASE”

NB: .trim() will not remove the space between words.

With arguments



● .indexOf
let tvShow = “catdog”;

tvShow.indexOf(“cat”); // 0 - it starts at index 0
tvShow.indexOf(“dog”); // 3 - it starts at index 3
tvShow.indexOf(“z”); // -1 - not found

“baseball”.indexOf(“ball”); //4
“baseball”.indexOf(“b); //0 - tells you only the first instance
“Baseball”.indexOf(“b); //4 - case sensitive


● .slice()
Takes slices of an existing string and gives you a piece of it.

Ex: 1 argument - the index of the start of the slice
“Baseball”.slice(4); //”ball”

let sport = “Baseball”;
sport.slice(4); //”ball”
sport // “Baseball” - immutable

Ex: 2 arguments - the index of the start of the slice and of the end of the slice
“superhero”.slice(0,5); //”super” - non-inclusive (it ends at index 4)


● .replace()
It replaces part of a string

Ex:
“baseball is entertaining”.replace(“entertaining”, “ok”); //“baseball is ok”
“ha ha ha”.replace(“hee”); //”hee ha ha” - it only replaces the first one



STRING TEMPLATE LITERALS
Template literals are strings that allow embedded expressions, which will be evaluated and
then turned into a resulting string → interpolating data inside of a string.

Ex: `I counted ${3 + 4} sheep`; //“I counted 7 sheep”



4

Schule, Studium & Fach

Hochschule
Studium
Kurs

Dokument Information

Hochgeladen auf
1. mai 2024
Anzahl der Seiten
84
geschrieben in
2020/2021
Typ
Notizen
Professor(en)
Colt steele
Enthält
Alle klassen

Themen

9,46 €
Vollständigen Zugriff auf das Dokument erhalten:

Falsches Dokument? Kostenlos tauschen Innerhalb von 14 Tagen nach dem Kauf und vor dem Herunterladen kannst du ein anderes Dokument wählen. Du kannst den Betrag einfach neu ausgeben.
Geschrieben von Student*innen, die bestanden haben
Sofort verfügbar nach Zahlung
Online lesen oder als PDF

Lerne den Verkäufer kennen
Seller avatar
ilariacallegari

Lerne den Verkäufer kennen

Seller avatar
ilariacallegari -
Folgen Sie müssen sich einloggen, um Studenten oder Kursen zu folgen.
Verkauft
-
Mitglied seit
1 Jahren
Anzahl der Follower
0
Dokumente
1
Zuletzt verkauft
-

0,0

0 rezensionen

5
0
4
0
3
0
2
0
1
0

Kürzlich von dir angesehen.

Warum sich Studierende für Stuvia entscheiden

on Mitstudent*innen erstellt, durch Bewertungen verifiziert

Geschrieben von Student*innen, die bestanden haben und bewertet von anderen, die diese Studiendokumente verwendet haben.

Nicht zufrieden? Wähle ein anderes Dokument

Kein Problem! Du kannst direkt ein anderes Dokument wählen, das besser zu dem passt, was du suchst.

Bezahle wie du möchtest, fange sofort an zu lernen

Kein Abonnement, keine Verpflichtungen. Bezahle wie gewohnt per Kreditkarte oder Sofort und lade dein PDF-Dokument sofort herunter.

Student with book image

“Gekauft, heruntergeladen und bestanden. So einfach kann es sein.”

Alisha Student

Häufig gestellte Fragen