Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality✓ Free Actions
Free to watch • No registration required • HD streaming
Embora eu tenha começado, de verdade, com Logica de programação, bem aqui, eu não vou abrir os trabalhos com esse tema exatamente. Vou voltar nele, sem dúvida, inclusive por este mesmo link, mais tarde.
A questão aqui é que JS está mais presente agora e mais do que presente, se fazendo muito necessário. Assim que, também, ao invés de começar pelo meu começo em JavaScript eu optei por acompanhar um curso de introdução ao JavaScript e em paralelo a ele um curso de introdução a ES6, ambos pelo SCRIMBA.
São 24 lições de ES6 e 25 lições de JS. Criei também um repositório no Github para disponibilizar eventuais arquivos, projetos e exercícios que sejam desenvolvidos durante os cursos.
Morning #devs 🌞 I started learning 👨🏻💻 #react from #scrimba and I can say it's the best platform to learn anything! I really liked the interactive videos from instructor! It feels like I'm learning from my personal instructor!👩🏾🏫 I'm using #webstorm as my IDE for react because we all know it's the best IDE for any #javascript framework! 🤪 I'll spend my weekend covering up basics of react and then start my journey in react native🤑 What are your weekend plans? Tell me in the comments!!❤️ Have a great day and weekend ahead!✨🦋 #code #coding #codinglife #developer #developerlife #webdev #webdeveloper #frontend #frontenddeveloper #fullstack #fullstackdev #programmer #python #django #github #git #programming #programmerlife #javascript #php #wordpress #nodejs #devlife #html #css3 #design (at Surat, Gujarat) https://www.instagram.com/p/B6SG8GQgrR8/?igshid=1oortmf2gfevb
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality✓ Free Actions
Free to watch • No registration required • HD streaming
Learn the most popular programming language on the web
Notes From Scrimba’s Introduction to JavaScript Course
Scrimba is a site where you can learn how to code. The platform offers a lot of courses and tutorials about CSS, HTML, JavaScript, and more. You’ll need an account to take these courses and tutorials, but it’s all for free.
For the lessons - it’s like watching YouTube videos. You’ll be hearing audio and seeing visuals of the written code. But the difference is that you can actually play around with the codes. You can try it out yourself.
I decided to try taking the Introduction to JavaScript course from Scrimba. This post is where I’ll be noting down what I learned from said course.
Variables
use let instead of var to store values that will be overwritten
let example = 'sample'; console.log(example);
Console.log(example) will print the current value of example.
const - cannot be used to overwrite values
const example = "example" example = "another example"
If you try to change the value associated with example, this won’t work if you use const. You will get an error in the above example.
use let and const to store data or values.
Strings
let name = "Loki"; console.log(typeof name);
typeof will print the type of data (data type). In the example above, it’s string.
You can use either “” or ‘’ . Just make sure the quotes match on both sides.
let firstName = "Loki";let lastName = "Laufeyson"; console.log(`${firstName} ${lastName}`);
Use ` ` and ${} (string interpolation) to print out variables instead of using the + (firstName + lastName) to concatenate or add strings together. In the example above, the console.log will print out the values of the first and last name (Loki Laufeyson).
let firstName = "Harry"; let lastName = "Potter"; console.log(`${firstName} ${lastName} is a wizard.`);
This example will print out “Harry Potter is a wizard.”
Another example:
let school = "Hogwarts School of Witchcraft and Wizardry"; let friends = "Ron and Hermione"; let wizard = "Harry Potter"; console.log(`${wizard} goes to ${school} with his friends ${friends}.`); Harry Potter goes to Hogwarts School of Witchcraft and Wizardry with his friends Ron and Hermione.
let fullName = `${firstName} ${lastName}`; console.log(fullName);
This will print out “Harry Potter”.
A method is a function. A function is a set of instructions, essentially how we’re going to store our code.
use .length to find out the length of the string being printed.
use .trim() to remove empty spaces.
let firstName = "Hermione"; let lastName = "Granger"; console.log(` ${firstName} ${lastName} `.length); console.log(` ${firstName} ${lastName} `.trim().length); 50 16
In the example above, using .length will print out 50 because of all the empty spaces. After using .trim(), the empty spaces will be removed, so the length becomes 16.
.toUpperCase() - capitalize all the letters
.toLowerCase() - lowercase all the letters
let firstName = "Ron"; let lastName = "Weasley"; console.log(`${firstName} ${lastName}`.toUpperCase()); console.log(`${firstName} ${lastName}`.toLowerCase()); RON WEASLEY ron weasley
.split() - need a parameter (needs a value that goes inside the parenthesis)
The typeof of the first 2 are numbers because we’re pulling numbers from them. The typeof of toFixed is a string because it converts the numbers when you round it off or adds or drops values.
Booleans
Either true or false values. There are also truthy or falsy values.
let sampleBoolean1 = true; let sampleBoolean2 = false; console.log(Boolean(sampleBoolean1)); //prints true console.log(Boolean(sampleBoolean2)); //prints false
let sampleNumber = 12345; console.log(Boolean(sampleNumber)); //prints true
In the second example, true is printed because the number is a truthy value.
let example1 = false; let example2 = true; let example3 = null; let example4 = undefined; let example5 = ''; let example6 = NaN; let example7 = -5; let example8 = 0; console.log(Boolean(example1)); //prints false console.log(Boolean(example2)); //prints true console.log(Boolean(example3)); //prints false console.log(Boolean(example4)); //prints false console.log(Boolean(example5)); //prints false console.log(Boolean(example6)); //prints false console.log(Boolean(example7)); //prints true console.log(Boolean(example8)); //prints false
null - value that we are referencing, value will be set later on, used as a placeholder, as an empty falsy value
undefined - falsy value, a variable that wasn’t defined, variable or property that doesn’t exist that you’re trying to reference, there’s usually a bug in your code if you see this
Empty strings like in example5 are falsy values. But if you add a space there, it will return as true.
How come triwizardChampions and gobletofFire are identical when you only added “Harry” to gobletofFire? The reason is because “when you’re dealing with arrays and objects, you’re passing by reference”. This means gobletofFire is setting a reference or referring to triwizardChampions. It’s not actually creating a new array, so when you push to gobletofFire, you’re actually pushing to triwizardChampions.
To create a new array and not pass by reference anymore or still have the values of the previous array, use ... (spread operator) like this:
let triwizardChampions = ["Cedric", "Viktor", "Fleur"]; let gobletofFire = [...triwizardChampions]; gobletofFire.push("Harry"); console.log(triwizardChampions); console.log(gobletofFire);
The ... will take the values of the previous array and push or add them into the new array.
You can also use .map to create a new array.
let triwizardChampions = ["Cedric", "Viktor", "Fleur"]; let gobletofFire = triwizardChampions.map((members) => { return members }); gobletofFire.push("Harry"); console.log(triwizardChampions); console.log(gobletofFire);
.splice(1, 3, “siren”, “harpy”) means add 2 elements after the 1st element (in the above example, that’s after “dragon”), and remove “sphinx”, “gryffin”, and “basilisk”.
slice method - using this will give you a new array with copied values from the original array. The original array will not be modified or changed.
You can add optional arguments to the slice method (the values in the parenthesis). The first optional argument or the first number in the parenthesis refers to the beginning index, meaning where do you start cutting. The second one refers to the ending index (meaning where to end the selection/cutting), which is non-inclusive (meaning it’s not included).
If you don’t put an argument in the parenthesis (empty parenthesis), then you’ll just copy the first array into the second array.
let slytherins = ["Draco", "Goyle", "Crabbe"] let slytherinsCopy = slytherins.slice() slytherinsCopy (3) ["Draco", "Goyle", "Crabbe"]
So slytherins and slytherinsCopy will have the same values.
If you only add one argument (one number in the parenthesis) to the slice method, then you will get a copy from the specified index (this starts at 0) up to the end of the array.
let weasleys = ["Bill", "Charlie", "George", "Fred"] let weasleysCopy = weasleys.slice(2) weasleysCopy (2) ["George", "Fred"]
So weasleys.slice(2) means get values from the weasleys array starting from “George” (because the count starts at 0: Bill is 0, Charlie is 1, George is 2) up to the end of the weasleys array.
You can also specify a negative number inside the slice parenthesis. If you do this, the index counting starts from the end of the array.
var blackFamily = ["Sirius", "Regulus", "Bellatrix", "Andromeda", "Narcissa"] var blackSisters = blackFamily.slice(2, 5) blackSisters (3) ["Bellatrix", "Andromeda", "Narcissa"] var blackBrothers = blackFamily.slice(0, 2) blackBrothers (2) ["Sirius", "Regulus"]
.slice(2, 5) means start cutting from 2 (Sirius is 0, Regulus is 1, Bellatrix is 2) and end at Narcissa (use 5 because the index counting starts from 0 and this second number isn’t included in the count).
.slice(0, 2) means start cutting from 0 (Sirius is 0) and end at Regulus (use 2 because the index counting starts at 0 and this second number isn’t included in the count).
You can also slice characters from a string or even characters from a specific string in an array.
let potterFamily = ["James", "Lily", "Harry"] let harry = potterFamily[2].slice(2, 4) harry "rr"
potterFamily[2] means select “Harry” out of the potterFamily array.
.slice(2, 4) means start taking out the letter r (H is 0, a is 1, r is 2) then take out another r. The second r is 3, but you use 4 because the second number is not included in the count, so if you use 3, only 1 r will be removed.
var hpSpell = prompt("Harry Potter spell?", "Alohomora"); var spellLength = hpSpell.length; //this will check the number of characters in the hpSpell variable alert(hpSpell.slice(1, spellLength - 1)); //this will print the second through next-to-last characters of the hpSpell variable. In this case, it will print lohomor
.splice method - changes the contents of an array, can be used to add or remove/delete items from an array. This modifies the original array and returns a new array. Can take 3 arguments (the ones in the parenthesis).
The first number refers to the index where you want to start deleting or adding elements
The second number refers to the number of elements you want to remove
The third is optional and this refers to the new elements you want to add to the array
If there’s only one argument in the parenthesis, then this means all the items after the provided starting point will be removed from the array. In this example, .splice(2) will remove Draco from the array (Lucius is 0, Narcissa is 1, Draco is 2). So if you call malfoyFamily, only Lucius and Narcissa will show up.
In the above example, .splice(2, 1) means remove the second element or value in the hogwartsProfessors array (McGonagall is 0, Flitwick is 1, Hagrid is 2). The 1 means only remove one item from the array, so only Hagrid was removed.
In the example above, the 2 in the splice parenthesis means remove an element from the hogwartsClasses array starting from 2 (remember that the counting starts from 0, so 2 refers to Flying). The 1 in the parenthesis means only remove one element from the hogwartsClasses array. The rest of the classes (Divination, etc) will be added to the hogwartsClasses array in the place of the Flying element.
If you put 0 in the second argument, it means do not remove anything from the array. In the example above, “Hogwarts” was added in the location specified in the first argument (the 1).
Objects
{}
can take in what are called properties
let sampleObject = { firstName: "Sirius", lastName: "Black" }; console.log(sampleObject.firstName); //will print Sirius console.log(sampleObject.lastName); //will print Black
Property names are also referred to as keys. Object.keys will print out all the keys except the nested keys (so just fullName instead of also including firstName and lastName).
dracoInfo2.lastName.mothersLastName = "Black"; console.log(dracoInfo2); //will result in error, can't add mothersLastName because lastName is not defined as an object. But since dracoInfo2 is defined, it's possible to add or assign the lastName property to it
To create a new object with the value from the original object, do this:
Object.assign - takes in two values inside the parenthesis, the first is what you want to assign it to, in the above example, it will be assigned to an empty object. The second value is what we’re going to assign it to.
Since we’re now instantiating a new object, the dracoInfo object will no longer pass by reference to dracoInfo2, so dracoInfo2 will now be a new object.
Relational Operators
Relational operators will compare 2 items and return a true or false value.
let example1 = 10; let example2 = 15; console.log(example1 >= example2); //will print false because 10 is not greater than or equal to 15
=== strictly equals comparison compares the value and type. This is same for !==
let example1 = 10; let example2 = '10'; console.log(typeof example1); //prints number console.log(typeof example2); //prints string console.log(example1 === example2); //triple equals sign will check not only the value but also the data type. This is why this will print false - because while the values of example1 and example2 are the same, their data types are not the same
== there is also a less strict one that compares only the value. This is same for !=
let example1 = 10; let example2 = 12; console.log(typeof example1); //will print number console.log(typeof example2); //will print number console.log(example1 == example2); //will return false because 10 is not equal to 12. The double equals sign will just check if the values are the same or not.
let example1 = 10; let example2 = '10'; console.log(typeof example1); //will print number console.log(typeof example2); //will print string becuse there are quotes around the number console.log(example1 == example2); //will print true even though example2's type is now a string because the two equals sign is only checking if the values of the variables are the same
let example1 = 5 === 5; let example2 = 5 == '5'; let example3 = 6 != '6'; let example4 = 7 !== '7'; console.log(example1); //prints true console.log(example2); //prints true console.log(example3); //prints false console.log(example4); //prints true
Increment (++) and Decrement (--)
let sampleIncrement = 1; sampleIncrement++; console.log(sampleIncrement); //will print 2
let sampleDecrement = 2; sampleDecrement--; console.log(sampleDecrement); //will print 1
To add or subtract more than 1, do this:
let sampleIncrement = 1; sampleIncrement +=5; console.log(sampleIncrement); //will print 6
let sampleDecrement = 5; sampleDecrement -=3; console.log(sampleDecrement); //will print 2
You can also multiple or divide or use the modulus operator: *= for multiplying and /= for dividing and %= for modulus
let example1 = 5; example1++; console.log(example1); //prints 6 let example2 = 5; ++example2; console.log(example2); //prints 6
let example1 = 5; console.log(example1++); //prints 5 let example2 = 5; console.log(++example2); //prints 6
Adding ++ at the end of a value means it will be added after the line of code. If you add ++ at the beginning, it will be added within the line of code. This is the same with -- (for subtraction).
Else if - only runs if the if statement doesn’t run
Else - the default value, if both the if and else if statement fail, then this one will run instead
let hpCharaInfo = "Harry Potter"; switch(hpCharaInfo) { case "Harry Potter": console.log("You are the main character."); break; case "Sirius Black": case "James Potter": case "Remus Lupin": console.log("You are one of the Marauders."); break; case "Peter Pettigrew": console.log("You are a traitor."); break; case "Rowena Ravenclaw": case "Salazar Slytherin": case "Godric Gryffindor": case "Helga Hufflepuff": console.log("You are one of the Hogwarts Founders."); break; case "Severus Snape": console.log("You are a spy."); break; case "Nymphadora Tonks": case "Kingsley Shacklebolt": console.log("You are an auror."); break; case "Minerva McGonagall": case "Filius Flitwick": case "Pomona Sprout": console.log("You are one of the Hogwarts Heads of Houses."); break; case "Bellatrix Lestrange": case "Lucius Malfoy": console.log("You are one of the Death Eaters."); break; default: console.log("Please enter your name to find out your status or role in the Harry Potter series."); }
No need to add a break after the default value (the last one in the example above).
For Loop
Start by instantiating a variable, this is the counter, usually initialized by i for iteration (this is the i = 0, the first part in for loops).
The second part of the for loop will continue to run until the statement is no longer true.
let total = 0; for (let i = 0; i < 5; i++) { console.log(i); //will print 0, 1, 2, 3, 4 }
In the example above, the for loop keeps on running until i is no longer less than 5.
To add the values of i to total, do this:
let total = 0; for (let i = 0; i < 5; i++) { total += i; } console.log(total); //the for loop will add the values of i to total, so this will now print 10
let numArray = [10, 20, 30, 40, 50, 60, 70, 80]; for (let i = 0; i < numArray.length; i++) { console.log(numArray[i]); //will print all the values of the numArray total += numArray[i]; }
let total = 0; let numArray = [10, 20, 30, 40, 50, 60, 70, 80]; for (let i = 0; i < numArray.length; i++) { total += numArray[i]; } console.log(total); //prints 360
use numArray[i] (the i is what the counter is in the for loop, so this can change to any variable depending on what is used to instantiate the for loop) to access all the values of the array. If you just want to access a specific value in the array, use the index number. For example, if you want to access the first value in the numArray, use numArray[0].
var nums = [10, 20]; for (var i = 0; i < nums.length; i++) { if (nums[i] === nums[i]) { alert(nums[i]); break; } }
break; stops the loop. The example above will only show one alert.
While
It runs until a value is no longer true.
let count = 0; while (count > 20) { count++; //as long as the value of count is greater than 20, then the while statement will continue to run } console.log(count); //prints 0. The while statement above doesn't run because 0 (the current value of count) is not greater than 20.
Do While
This will run at least once.
let count = 0; do { count++; if(count >= 20) { break; } } while (false) console.log(count); //prints 1 because the do statement runs
Functions
A way of storing our code, so we can call it again and again and reuse it.
function sampleFunction() { console.log("This is a sample function"); }
In the example above, nothing will happen because you need to call or invoke the function first. You can do this by calling it by its name.
sampleFunction(); This is a sample function
Functions can take in parameters (the ones inside the parenthesis). You can add multiple parameters.
function add(num1, num2) { return num1 + num2; } console.log(add(10, 6)); //prints 16 because the function adds the values of num1 and num2 console.log(add(15, 7)); //prints 22 console.log(add(20, 5)); //prints 25
return will allow you to return a value.
function add() { return 5; } console.log(add()); //prints the value that is being returned. In this case, it's 5
return keyword can return a number, string, boolean, or whatever it is you need.