100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4,6 TrustPilot
logo-home
Samenvatting

Samenvatting JavaScript

Beoordeling
-
Verkocht
2
Pagina's
11
Geüpload op
16-12-2021
Geschreven in
2021/2022

Samenvatting van het begrip Javascript. alle te kennen informatie verwerkt in dit bestand. van het keuzevak creating value using social media van Jan Moons.










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

Documentinformatie

Geüpload op
16 december 2021
Aantal pagina's
11
Geschreven in
2021/2022
Type
Samenvatting

Onderwerpen

Voorbeeld van de inhoud

JAVASCRIPT
VARIABLES
New variables in JavaScript are declared using one of three keywords: let, const, or var.

let allows you to declare block-level variables. The declared variable is available from the block it
is enclosed in.

let a;


let name = 'Simon';


The following is an example of scope with a variable declared with let:

// myLetVariable is *not* visible out here




for (let myLetVariable = 0; myLetVariable < 5; myLetVariable++) {


// myLetVariable is only visible in here


}




// myLetVariable is *not* visible out here


const allows you to declare variables whose values are never intended to change. The variable is
available from the block it is declared in.

const Pi = 3.14; // variable Pi is set


Pi = 1; // will throw an error because you cannot change a constant variable.


varis the most common declarative keyword. It does not have the restrictions that the other two
keywords have. This is because it was traditionally the only way to declare a variable in
JavaScript. A variable declared with the var keyword is available from the function it is declared in.

var a;


var name = 'Simon';


An example of scope with a variable declared with var:

// myVarVariable *is* visible out here

, for (var myVarVariable = 0; myVarVariable < 5; myVarVariable++) {


// myVarVariable is visible to the whole function


}




// myVarVariable *is* visible out here


If you declare a variable without assigning any value to it, its type is undefined.

An important difference between JavaScript and other languages like Java is that in JavaScript,
blocks do not have scope; only functions have a scope. So if a variable is defined using var in a
compound statement (for example inside an if control structure), it will be visible to the entire
function. However, starting with ECMAScript 2015, let and const declarations allow you to create
block-scoped variables.


OPERATORS

JavaScript's numeric operators are +, -, *, / and % which is the remainder operator (which is the
same as modulo.) Values are assigned using =, and there are also compound assignment
statements such as += and -=. These extend out to x = x operator y.

x += 5;


x = x + 5;


You can use ++ and -- to increment and decrement respectively. These can be used as a prefix or
postfix operators.

The + operator also does string concatenation:

'hello' + ' world'; // "hello world"


If you add a string to a number (or other value) everything is converted into a string first. This
might trip you up:

'3' + 4 + 5; // "345"


3 + 4 + '5'; // "75"


Adding an empty string to something is a useful way of converting it to a string itself.

Comparisons in JavaScript can be made using <, >, <= and >=. These work for both strings and
numbers. Equality is a little less straightforward. The double-equals operator performs type
coercion if you give it different types, with sometimes interesting results:

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
Handelswetenschapperugent Universiteit Gent
Bekijk profiel
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
145
Lid sinds
5 jaar
Aantal volgers
102
Documenten
14
Laatst verkocht
1 week geleden
Handelswetenschapper @Ugent

3,4

10 beoordelingen

5
3
4
1
3
4
2
1
1
1

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 Bancontact, iDeal of creditcard en download je PDF-document meteen.

Student with book image

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

Alisha Student

Veelgestelde vragen