Intro to javascript (6:27)

DavidCoulter17 64 views 40 slides Jun 27, 2017
Slide 1
Slide 1 of 40
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40

About This Presentation

Thinkful Intro to JS 6/27 at In3 DC


Slide Content

Intro to JavaScript
June 2017
bit.ly/tf-intro-js

About me
•Tyler Brewer
•Software Developer at Excella
Consulting & Mentor at
Thinkful
•Thinkful Grad

About TAs
•David Coulter
•Program Manager, Thinkful DC
•Formerly National Geographic,
FEMA, other stuff
•Brittany Walker
•Current Thinkful Student
•Super awesome

About you
•What’s your name?
•Why are you interested in learning JS?

About us
We train developers and data
scientists through 1-on-1
mentorship and career prep

Format for tonight
•Basics of how the web works
•Background about Javascript
•Review key Javascript concepts
•Practice with some challenges
•Next steps

What is programming?
Programming is writing instructions for a computer to
execute. Programming is problem-solving.

Programming is a process
1.Defining problems
2.Finding solutions to those problems
3.Implementing those solutions in a language your
computer can understand

Perception

Reality

How the web works
Type a URL from a client (e.g. google.com)
Browser communicates with DNS server to
find IP address
Browser sends an HTTP request asking
for specific files
Browser receives those files and renders
them as a website

Clients / Servers
Client (sends requests)
Frontend Developer
Manages what user sees
Server (sends response)
Backend Developer
Manage what app does

Brief history of Javascript
•Written by Brendan Eich in 1995 for Netscape
•Initial version written in 10 days
•Completely unrelated to Java, but maybe named after
it to draft off its popularity
•Over 10 years, became default programming
language for browsers
•Continues to evolve under guidance of ECMA
International, with input from top tech companies

This makes it a good place to start
•Has large community of developers, libraries and
frameworks
•Lots of job opportunities
•Also the syntax is easier to understand for first-time
developers

Are we learning frontend or backend?
100% of client-side web development is in Javascript.
You can also use Javascript to write server-side code
thanks to Node.js. So technically both!

Concepts we’ll cover
•Variables
•Data types: strings, numbers, booleans
•Functions

Note on where to write you code
When working as a programmer, you’ll use a text editor
or an “Integrated Development Environment” (IDE).
Tonight we’re using JSBin so we can skip setup, see
results immediately and easily share code

Javascript variables
•A variable is a name that is attached to a value — it gives
us a shorthand way to refer to the value elsewhere
•Helps us remember things while we’re executing a
program: “managing state”
•Example on JSBin: http://bit.ly/js-example-one

Examples
•Declaring variable: var firstVariable;
•Assigning value: firstVariable = 6;
•Retrieve value: alert(firstVariable)
Example on JSBin: http://bit.ly/js-example-two

Best practices for naming variables
•Names should be (extra) descriptive: “numberOfCats”
is better than “x”
•Use camelCasing where first word starts with lower
case, subsequent words are upper case
•Must start variable names with a letter

What values can be assigned to a variable?
•String
•Number
•Boolean
•Also Null, Undefined, Arrays, and Objects

Introducing strings
We use strings a lot. Strings are created with opening
and closing quotes (either single or double):
var foo = ‘bar’;
var bar = “foo”;

Combining (or “concatenating”) strings
Javascript lets you combine two strings by using the +
operator. Let’s try it in the console!
var host = “Thinkful”;
var className = “Intro to Javascript”;
console.log(className + “ with “ + host);
=> Intro to Javascript with Thinkful

Quick challenge
•Open JSBin in your browser
•Store your first name in one variable
•Store your last name in another variable
•Combine the two and log your full name

Introducing numbers
The number type in Javascript is used to represent all
kinds of numbers, including integers and decimals.
var integerNumber = 3;
var floatingPointNumber = 3.00;

Quick challenge
•Open JSBin
•Store two numbers in two different variables
•Add the two numbers and log to console
•Multiply the two numbers and log to console

Introducing booleans
Boolean is just a fancy word for “true” or “false”
var loggedIn = true;
if (loggedIn == true) {
alert(“loggedIn was set to true!”)
}

Basic functions
A function lets you separate your code into bite-sized
pieces which you can use over again.
When you write a function to use later, you are
“declaring” it. When you use (or run) that function you
are “calling” it.

Example
Declaring a function
function doSomething() {
alert(“Done!”);
}
Calling a function
doSomething();

More about basic functions
•Functions can save us time because we can use them
over and over code. They are like building blocks.
•Functions make your code more organized and easier
to read
•Javascript has many built-in functions — you’ve already
used a couple!
•In writing less trivial programs, you’ll write many, many
functions

Challenge #1
•Go to JSBin.com, make sure auto-run with Javascript
isn’t selected
•Declare and call this function:
function myFirstFunction() {
console.log(“Hello World!”);
}
myFirstFunction();
•Click “Run with JS” to see output in console

Challenge #2
•Open JSBin
•Write a function that logs your name
•Write a function that adds two numbers and logs the
result
•Call both functions

More advanced functions — parameters and return
•We can “give” a function some values to use. We call
the values we send into a function “parameters”
•We can have a function give a single value back. We
use a “return” statement to do that.
•We define what parameters the function accepts when
we declare the function.
•We send the actual parameters when we call the
function — we put those parameters in the parentheses.
Example: addTwoNumbers(2, 3);

An example
function addTwoNumbers(firstNumber, secondNumber) {
return firstNumber + secondNumber;
}
var result = addTwoNumbers(2, 3);
alert(result);

Challenge
•Open JSBin
•Write a function that takes your first name and your last
name as two parameters
•Return a string with your full name
•Call that function

Ways to keep learning
Level of support
Learning methods

1-on-1 mentorship enables flexibility
325+ mentors with an average of 10
years of experience in the field

Support ‘round the clock

Our results
Job Titles after GraduationMonths until Employed

Try us out!
•Learn HTML/CSS and
JavaScript
•Continue with Node,
React, and more
•We offer both Web
Development and
Data Science
Bootcamps
•Talk to some one
from Thinkful if
you’re interested!
Tags