lesson1
This commit is contained in:
88
nodeJS/Learning/01/index.js
Normal file
88
nodeJS/Learning/01/index.js
Normal file
@@ -0,0 +1,88 @@
|
||||
//Javascript Tutorial
|
||||
|
||||
// Means Comment
|
||||
|
||||
/* hehhe
|
||||
wow this is fun
|
||||
i am dumb */
|
||||
|
||||
// Hello I
|
||||
// can
|
||||
// do this now
|
||||
|
||||
// variable (var): want to make a empty box called dog, but expecting sth in there later
|
||||
// Can later assign Lucy to this box. variable originally empty box name is dog, but then the variable value is Lucy
|
||||
|
||||
var dog;
|
||||
dog = "Buddy";
|
||||
console.log(dog);
|
||||
// var is the old name, it is a bad practice
|
||||
|
||||
//let: will change, e.g. box called cat but give it a different cat (value) every single time
|
||||
let cat;
|
||||
cat = "Tom";
|
||||
console.log(cat);
|
||||
cat = "John";
|
||||
console.log(cat);
|
||||
|
||||
//const: constant, thing in box will never change
|
||||
const bird = "sparrow";
|
||||
console.log(bird);
|
||||
|
||||
//Data types: type of things u put in variable, e.g. tell box to put in specific type of value
|
||||
|
||||
//Primitives Data Types
|
||||
//String, Number, Boolean, Undefined, Null
|
||||
|
||||
//String: anything in single or double quotation, can type anything, show direct thing in quotation
|
||||
const funnystring = "John Doe";
|
||||
console.log(funnystring);
|
||||
|
||||
//String concatenation
|
||||
const name1 = "John";
|
||||
const name2 = "Doe";
|
||||
const fullName = `The full name is ${name1} ${name2}`;
|
||||
console.log (fullName);
|
||||
console.log ("The full name is" + name1 + " " + name2);
|
||||
|
||||
//String Escape Character, \ escapes the quotation
|
||||
console.log ("Ronald said \"It'\s raining outside\"");
|
||||
|
||||
//String indexing: the computer recognizes it as each number assigned: every single letter on the word will have a index
|
||||
const string = "javascript bob";
|
||||
console.log(string[0]); //j
|
||||
console.log(string[5]);
|
||||
console.log(string[11]);
|
||||
|
||||
|
||||
// Number: just a number (both one with decimal or one without)
|
||||
let age = 20;
|
||||
console.log (age);
|
||||
age = age + 15;
|
||||
console.log (age)
|
||||
|
||||
//NaN: not a number
|
||||
let result = "Hello"/2;
|
||||
console.log(result);
|
||||
|
||||
//infinity
|
||||
let infinity = 1/0
|
||||
console.log(infinity)
|
||||
|
||||
//Boolean: true or false statements, all comparisons, !==" "
|
||||
console.log (1>2);
|
||||
console.log (5<7);
|
||||
console.log ("tiffany" !== "Tiffany")
|
||||
|
||||
let tiffany = "tiffany"
|
||||
let haha = "Tiffany"
|
||||
tiffany = haha
|
||||
console.log (tiffany == haha)
|
||||
|
||||
//Undefined: did not give x anything
|
||||
let x;
|
||||
console.log(x);
|
||||
|
||||
//Null: telling them theres nothing in the code
|
||||
let y = null;
|
||||
console.log(y);
|
||||
Reference in New Issue
Block a user