JavaScript Notes
Function: console.log():
- string can be added into the brackets
- the function outputs a message to the web console
- only a single string can be inputted into function
console.log("hello!")
Setting a variable:
- "var msg = " captures data of the string (variable of string)
- console.log shows output
//defining variable
var msg = "example message";
//logging message
console.log(msg)
Defining functions:
- the following code has two steps: defining the function and calling the function
//defining function
function logIt(output) {
console.log(output);
}
//calling function
logIt(msg);
JavaScript as a Dynamic (loosely typed) language:
- dynamic/loosely typed means you don't have to specify what type of information will be stored in a variable beforehand
- the variable type is determined while the code is running, which is similar to Python
//string:
console.log("hello")
//number:
console.log(22)
//generic object: array (similar to python list)
console.log([1,2,3])