100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
College aantekeningen

Modern Javascript - Essentials

Beoordeling
-
Verkocht
-
Pagina's
84
Geüpload op
01-05-2024
Geschreven in
2020/2021

Online course notes on JavaScript

Instelling
Vak











Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Studie
Vak

Documentinformatie

Geüpload op
1 mei 2024
Aantal pagina's
84
Geschreven in
2020/2021
Type
College aantekeningen
Docent(en)
Colt steele
Bevat
Alle colleges

Onderwerpen

Voorbeeld van de inhoud

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
€8,83
Krijg toegang tot het volledige document:

100% tevredenheidsgarantie
Direct beschikbaar na je betaling
Lees online óf als PDF
Geen vaste maandelijkse kosten

Maak kennis met de verkoper
Seller avatar
ilariacallegari

Maak kennis met de verkoper

Seller avatar
ilariacallegari -
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
0
Lid sinds
1 jaar
Aantal volgers
0
Documenten
1
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen