New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

JavaScript Notice to Ninja Notes

by: Nana Nguyen

JavaScript Notice to Ninja Notes CIS 111

Nana Nguyen
GPA 3.5
Intro Web Programming >4
Hennessy M

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Greetings! These are my notes from the class Computer Information Science CIS 111. I work so hard on these so please enjoy and excuse for any of my mistakes (:
Intro Web Programming >4
Hennessy M
Class Notes
25 ?




Popular in Intro Web Programming >4

Popular in Computer Science and Engineering

This page Class Notes was uploaded by Nana Nguyen on Monday November 9, 2015. The Class Notes belongs to CIS 111 at University of Oregon taught by Hennessy M in Fall 2015. Since its upload, it has received 53 views. For similar materials see Intro Web Programming >4 in Computer Science and Engineering at University of Oregon.

Similar to CIS 111 at UO

Popular in Computer Science and Engineering


Reviews for JavaScript Notice to Ninja Notes


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 11/09/15
Overview Java script Tuesday November 3 2015 254 AM JavaScript was created in 1995 by NetScape And quickly spread and become popular tha is now considered the language of the Web JavaScript is far from perfect having a number of flaws It is missing some important programming constructs including modules and private functions that are considered standard in many modern programming languages Programming is about making computers do whatyou want It is a series of instructions that tell computer how to perform a task Scripting languages are interpreted high level languages that are translated into machine code at run time They typically run slower than compiled languages but they are far more sophisticated increasing blurring line between compiled and interpreted languages JavaScript is a high level language that is compiled at run time It requires an engine that is responsible for interpreting programs and runningthem JavaScript wasfrequently used to create annoying pop up adverts and browser sniffing 0 Browser sniffing the process ofdetecting which browserwas being used to view a web page JavaScript only need a text editor and browser to write THREE LAYERS OF THE WEB Nearly all web pages are made up of three key ingredients HTML CSS and JavaScript HTML is forthe content CSS is the presentation layer JavaScript adds the interactivity A web page should be able to function with just the HTML layer which could be used without the CSS layer from the site A website usingjust the HTML layeer will be in its purest form and look old school but sti be fully functional U nobtrusiveJavaScript is when the JavaScript code is kept completely separate from the HTML and CSS preferably in its own file This can be linked to using the same script tag and the src attribute to specify the file to link to ltscript srcquotjsscriptsjsquotgtltscriptgt GRACEFUL DEGRADATION AND PROGRESSIVE ENHANCEMENT Graceful degradation is the process of building a website so that it works best in modern It browserthat uses JavaScript but still works to a reasonable standard in older browsers o if JavaScript or some of its features are unavailable 0 Example broadcast in high definition would work best on HD television but still work on standard TV Progressive enhancement is the process of building a web page from the group up with a base level of functionality and then adding extra enhancements if they are available in the browser 0 Example phone companies who offer a basic level ofphone calls but also provide extra services including call waiting and caller ID if the phone could support it ID attribute is used as a hook to access different elements of the page Script tag link gtlt JavaScript file thejs folder sthe inside CHAP 2 PROGRAMMING BASICS Tuesday November 3 2015 337 AM Comment is a piece of code that is ignored by the language it does not do anything Yet comments are extremely important well commented code is the hallmark of a ninja programmer It makes easier for anybody reading the code to understand the progress Two types of comment 0 Single Line states with and finish at the end of the line 0 Multiline comments start with and finish with Grammar Cstyle syntax A JavaScript is made up ofa series of statements Each would end with a new line or semicolon It isn39t necessary to use a semicolon to terminate a statement because ofAutomatic Semicolon Insertion It would place automatically semicolons at the end of lines but it could be error prone and cause a number ofautomated services such as code minifies and validators to not work properly It39s best practice to combine each statement on a new line and terminated by a semicolon a quotHello Worldquot alert a A block is a series of statements that are collected together inside curly braces It does not need to be terminated by a semicolon this is a block containing 2 statements var a quothelloquot alert a Whitespace spaces tabs new lines is used to separate the different values in each statement There are 5 primitive data types string number Boolean undefined null Any value that is not one of the primitive data types listed is an object JavaScript has a special operator call typeof for finding out the type of a value An operator applies an operation a value which is known as the operand A unarvooerator requires one operand typeof quotHelloquot ltlt quotstringquot The operator is typeof and the string quothelloquot is the operand A binarv Operator requires two operands 3 5 The operator is and the numbers 3 amp 5 are the operands A ternary operator reuiq res 3 operands STRING is a collection of letters or characters We can create a string literal by writing a group of characters inside quote marks quothelloquot You can also create a string obiect using the string construction function new Stringquothelloquot gt this would create a new string that is the same as the string literal quothelloquot Yet it would be classed as an object rather than a primitive value Ifyou want to use double quote marks inside a string literal you need to use single quote marks to enclose the string If you use an apostrophe in string a double quote marks needs to be employed to enclose the string quotIt39s mequot Or we can use escaping the quotation mark by placing a backslash before the apostroph so that it appears as an apostrophe inside the string instead of terminating the string 39t39s me39 Escaping characters the backslash is used to escape special characters in strings single quote marks 39 doublequote marks quot end of line n carriage return r tab t Ifyou want to actually write a backslash you need to escape it with another backslash quotThis is a backslashquot ltlt quot This is a backslashquot VARIABLES are a way of storing a value in memory for later use In JavaScript we start b declaring a variable by using the keyword var You can even declare multiple variables at once var abc 3 variables declared at once ltlt undefined Rules for naming variables when naming variables it39s best to give them sensible name that describe what the variable represents answer is better than A variable name can start with any upper or loswer case letter an underscore or dollar symbolsS It can also contain numbers but cannot start with them Snamename firstName lastname addressline1 When using multiple wordsforvariable names Camel case starts with a lowercase letterand each new word is then capitalized firstNameAndLastName OR underscore separates each new word with an underscore firstnameandlastname ASSIGNMENT To assign a value to a variable use the operator Var name Jessequot declare the variable and assign it to a string at the same time ltlt quotJessequot Varx 2 y z quotHiquot y has only been declared its39 undefined Ilnrln39Finnr l UIIUMI quotqu STRING PROPERTIES AND METHODS Properties are information about the objector value while methods perform an action on the object or value either to change it or to tell us something about it Initially only objects have properties and methods JavaScript did overcome this by creating wrapper objects for primitive values We access the properties ofa string using dot notation This involves writing a dot followed by the property we are interested in Forinstance every string has a length property that tells us how many characters are use in string Name quotHeisenbergquot declare and assign a variable ltlt quotHeisenbergquot Namelength call the length method on name ltlt 10 All properties of primitive values are immutable which means that they39re unable to be changed A method is an action that a primitive value or object can perform To call a method use the dot operator followed by the name of method followed by parentheses a distinctive feature of method ends with parentheses NametoUpperCase 0 write a string in all capital letters ltlt quotHEISENBERGquot NametoLowerCase 0 write names in all lowercase letters ltlt quotheisenbergquot NamecharAt1 which character is at certain position ltlt quotequot Nameindex0fquotHquot find where a certain character or substring appears in a string ltlt quot0quot if a character does not appear in the string 1 will be returned Namelastlndex0fquotequot want the last occurrence ofa character or substring ltlt 7 quotJavaScriptquotconcatquotNinjaquot concatenate two or more strings together ltlt quotJavaScriptNinjaquot quot Helloquotconcatquot quot quotWorldquot quot quot ltlt quotHello Worldquot quotJavaquot quotScriptquot quotNinjaquot A short cut forstring concatenation is to use the symbo to add two strings together ltlt quotJavaScript Ninjaquot quot Hello World quottrim the space in the middle will be preserved ltlt quotHello Worldquot quot tt JavaScript Ninja rquot trim escaped tabs and carriage returns are also removed Another notation can use to access primitive value39s properties are SQUARE BRACKETS Name39ength39 note the property name is in quote marks ltlt 10 ltlt quotJavaScript Ninjaquot NUMBERS Number can be integers or floating point decimals JavaScripts does not distinguish between integers and floating point decimals as they both given the typeof quotnumberquot gt ECMAScript specification Also have a constructorfunction new Number3 NUMBER METHODS toExponential 5 toExponential gtgt quot5eOquot use two dots 5 toExponential gtgt quot5e0quot put a space before the dot 50toExponential gtgt quot5eOquot write integers as a decimal 5toExponential gtgt quot5e0quot place integers in parentheses Var number 5 gtgt 5 number toExponential gtgt quot5eOquot assign numberto a variable Var pi 3141592653589793 ltlt undefined PitoFixed 3 only one dot needed when using variables ltlt quot3142quot note that the value is returned as a string 325678 toPrecision2 rounds a number to fixed number ofsignificant figures ltlt quot33e 5 quot returned result as a string and use exponential notation ARITHMETIC OPERATIONS Additio Subtracti Multiplicat Division Remainderofdivision n on ion 5 43 6 11 6 7 37 236the same as asking quotWhat is the remainder when 23 is divided by6 using operator ltlt 93 gtgt 5 ltlt 42 042857 ltlt 5 14 CHANGING VARIABLES points O initialize points score to zero ltlt 0 points points 10increase value held in the points var by 10 ltlt 10 points 10 use operator for a shortcut ltlt 20 points5 decrease points by 5 ltlt 15 points 2 double points ltlt 30 points 3 divides value of points by 3 ltlt 10 points 7 change the value of points to the remainder if its current value is divided by 7 ltlt 3 INCREMENT VALUES points return 3 then increase points to 4 ltlt 3 points increase to 5 then return it ltlt 5 points return 5 then decrease points to 4 ltlt 5 points decrease to 3 then return it ltlt 3 INFINITY is a special error value in JavaScript that is used to represent any number that is too big forJavaScript to deal with 1e308 1 with 308 zeros ltlt 1e308 2e308 biggerthan 17976931348623157e308 ltlt Infinity 1e309 ltlt nfinity for neg no that is smallerthan 17976931348623157e308 10 ltlt Infinity obtained by dividing byO Smallest numberthat JavaScript can deal with is 5e324 Any number belowthis would evaluate to either 5e324 orO NaN is an error value that is short for quotNota Numberquot It is used when an operation is attempted and the result isn39t numerical quothelloquot 5 ltlt Nan Typeof Nan ltlt 39number39 TYPE OF COERCION is the process of converting the type ofvalue in the background to try and make an operation work quot2quot 8 ltlt 16 multiply a string and a number together JavaScript would coerce the string to a number quot2quot 8 ltlt quot28quot add the string and numbertogether JavaScript would convert number to a string and concatenate the two strings together CONVERT STRINGS TO NUMBERS IIIllsbn I II I answer quotbquot t 1 ltltb multiply numerical strIng by 1 WOUICI convert It Into number typeofanswer ltlt quotnumberquot answer quot5quot ltlt5 pace symbol before number string to convert to the integer typeofanswer ltlt quotnumberquot Numberquot5quot use Numberfunction to convert string to number CONVERT NUMBERS TO STRINGS 3 quot ltlt quot3quotadd empty string would coerce to convert no into a string String3ltltquot3quotuse String function toString method would change the base of number ie change number 10 in binary base 2 gt 10 toString2 ltlt 1010 after base 10 letters represent digits gt 1000000toString36a million in base 36 ltlt quotlflsquot PARSEINT PARSING NUMBERS convert numerical string to integer parselntquot1010quot 2converts from binary back to decimal ltlt 10 if a string starts with a number the parselnt use this number and ignore any letters come after Var address quot2213 Baker Streetquot ltlt undefined parselntaddress 10 ltlt 221 the result would return Nan if use Number function Numberaddress ltltNan parsent would remove anything after the decimal point NOT round number parselntquot24quot 10 ltlt 2 parseFloat convert string into floating point decimal number pareseFloatquot29quot10 ltlt 29 UNDEFINED is given value that have not been assigned a value It can occur if an object39s property does not exist or a function has a missing parameter quotI cannot find a value fo thisquot NULL means quotnovaluequot Undefined and null are both nonvaluevalues They behave slightly different yet still similar 10 null null behaves like zero ltlt 10 10 undefined undefined is not a number ltlt Nan Null is coerced to be 0 gt make the possible sum whereas undefined is coerced to be NaN make the sum impossible to perform Values tend to be set to undefined by JavaScript whereas values are usually set to null manually by the programmer BOOLEANS TRUE AND FALSE 7 values are always false gt falsy values double quoted empty string 39 39singe quoted empty string 0 Nan False Null undefined BooleanquotHellloquot ltlt true Boolean42 ltlt true Boolean 0 ltlt false LOGICAL OPERATOR Logical NOT place the Operator in front of a value will conert it to a Boolean and return the opposite value So truthy values will return false and falsy values will return true gt negation true ltlt false use double negation to find out if a value is truthy or falsy shortcut of Boolean quot ltlt false quothelloquot ltlt true 3 ltlt true ampamp Logical AND the logical ANDoperator works on 2 or more values and only evaluate to true if ALL the operands are truthy The returned value is the last truthv value if they are all true or the first falsv value if at least one of them is false 3 ampamp O returns 0 because it is falsy ltlt 0 Logical OR the OR operator works on two or more operands but evaluates to true ANY of the operands are true so it only evaluates false if both operands are falsy The returned value is the first truthv value if any ofthem are true or the last falsv value if all of them are false COMPARISON EQUALITY SOFT EQUALITY double equal operator HARD EQUALITY triple equals operator When the soft equality is used JavaScript will coerce two values to the same type whilst doing the comparison which could lead to strange results quot quot 0 ltlt true NaN is the only value in JavaScript that is not equal to itself NaN NaN ltlt false use function isNaN to test it nIIIIIIIII Ibldldl ltlt true isNaN does not work properly isNaNquothelloquot ltlt true because function converts string to a numberthen a string without numerals are converted to NaN gtgt isnan NaNsetthe variable isnan to be NaN ltlt NaN Notnan quothelloquot set variable notnan to quothelloquot ltlt quothelloquot Typeofisnan quotnumberquot ampamp isNaNisnan ltlt true Typeofnotnan quotnumberquot ampamp isNaNnotnan ltlt false INEQUALITY SOFT INEQUALITY HARD INEQUALITY GREATER THAN OR LESS THAN fa value is greater than another by operator gt If a value is less than another use operator lt Greater or equal operator gt Less than or equal operator lt But could be affected by type coercion gt use combination of the greater than operato logical OR and a hard equality 8 gt8 8 quot8quot ltlt false CHAP 3 ARRAYS LOGIC AND LOOPS Tuesday November 3 2015 816 AM ARRAYS is an ordered list of values It is a special built in object Var myArray ltlt l 1 Or var myArray new Array ltlt l l Var pizzas quotMargheritaquot quotMushroomquot quotSpinach amp Rocketquot quotPineapple amp Sweetcornquot Delete pizzas3 Remove values from Array use delete operator ltlt true Pizzas ltlt quotMargheritaquot quotMushroomquot quotSpinach amp Rocketquot undefined value quotPineapple amp Sweetcornquot in the index of 3 fourth entry has been deleted from array but the space is still occupied and contain value of undefined gt only remove pizza from the box and did not remov the box completely Pizzas3 ltlt undefined array stills has same no of elements and position can be referenced as an index but would return undefined V PROPERTIES AND METHODS Pizzasength find length of array Pizzaspizzasength1 find the last item in the array The length property of array is mutable gt can change Pizzaspop remove last item from an array Pizzaspushquotvauequot add a new value to the end of the array gt the method returns the new length of the array Pizzasshift remove the first item in the array Pizzasunshiftquotvauequot add newto the begginning ofthe array PizzasconcatquotSpicy Beefquot quotChick and Mushroomsquot merge an array with another or multiple arrays Only combine two arrays yet still remain pizza array Pizzas pizzasconcatquotSpicy Beefquot quotChicken and Mush roomquot pizzas array contain new strings Pizzasjoin turn the array into a string that comprises all the items in the arrays separated by commas Or pizzasjoinquot amp quot separator other than a comma Pizzasslice24 creates a subarray that starts from the third item index of 2 and finish at the fourth the item with index OM is not included This operation is non destructive no items are actually removed Pizzasspice21 quotChicken and Pepperquot Veggie Deluxequot remove items fron an array and then insert new items in theirplace ltlt quotPepperoniquot remove the item at index 2 1 item Pizzasspice40quotaquot insert quotaquot as the fifth item in the pizza array Pizzasspice21 remove the item at index 2 completely without adding Pizzasreverse reverse the orderof an array Pizzassort sort the order of array alphabetically Pizzasindex0fquotSpicy Beefquot find if a value is in array V While loops repeatedly run a block of code while a certain condition is true While condition Do something


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Amaris Trozzo George Washington University

"I made $350 in just two days after posting my first study guide."

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.