JavaScript
JavaScript
JavaScript: Node.js
JS types:
Examples:
var myName
var x5
var hi_there
referencing variables:
math operators:
addition:
var x = 22
var y = 4
var z = x+y
z = 26
subtraction:
z = x - y
z = 16
Order of operations:
(+ x - /) + x - /
repl.it = it allows to see how your code work without opening in a text editor
Functions:
where all the magic happens
- to stow routines
has two uses:
- executing a particular task
- computing and returning a value
- They run when they're invoked
format:
to invoke:
var calculation = makeSeven ()
Function arguments: arguments allow the function to play with outside data
var myFunction = function (arguments){
code to be executed
}
pratical use:
var computeProduct = function (num1, num2){
return num1 * num2
}
JS proprietary library:
math.random():
returns a random decimal between 0.00 and 1.00
uses: games
Math.round ()
it returns a round version of the number
Math.round(4.7)
returns 5
Math.floor(4.7)
returns 4
Math.power(base, exponent)
Math.power(2, 4)
returns 16
MDN: Ms. Eich, who created java script, is also the creator of Mozilla, therefore
Mozilla Developer Network
method length:
input:
var myName = "John"
myName.length
output:
4
concatenation:
combining strings, or other variables
console.log(fullName);
.slice(start)
creates a copy that has a prototype linked to it
input:
"MakerSquare".slice(5)
output:
"Square"
is the equivalent of crop in CorelDraw
alwaysbecommitting