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

JavaScrip Notice to Ninja Notes

by: Nana Nguyen

JavaScrip 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

These are summary notes from the book JavaScript: Notice to Ninja. There may be some skipped parts from the textbook that corresponds to the study guides from my course CIS 111.
Intro Web Programming >4
Hennessy M
75 ?




Popular in Intro Web Programming >4

Popular in Computer Science and Engineering

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

Popular in Computer Science and Engineering


Reviews for JavaScrip 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/08/15
JavaScript was created in 1995 by NetScape Browser sniffing the process of detecting which browser was being used to view a web page JavaScript only need a text editor and browser to write HTML is for the content CSS is the presentation laver JavaScript adds the interactivity Unobtrusive JavaScript 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 le to link to ltscript srcquotjsscriptsjsquotgtltscriptgtGraceful degradation is the process of building a website so that it works best in modern browser that uses JavaScript but still works to a reasonable standard in older browsers or if JavaScript or some of its features are unavailable 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 Example phone companies who offer a basic level of phone calls but also provide extra services including call waiting and caller ID if the phone could support it Comment is a piece of code that is ignored by the language it does not do anything It makes easier for anybody reading the code to understand the progress Two types of comment Single Line states with and finish at the end of the line Multiline comments start with and finish with Grammar Cstyle syntax A JavaScript is made up of a series of statements Each would end with a new line or semicolon It39s best practice to combine each statement on a new line and terminated by a semicolon A block is a series of statements that are collected together inside curly braces It does not need to be terminated by a semicolon 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 unary operator requires one operand A binary operator requires two operands3 5 The operator is and the numbers 3 amp 5 are the operands A ternary operator requires 3 operands STRING is a collection of letters or characters quothelloquot a string object using the string construction function new Stringquothelloquot gt If you 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 apostrophe so that it appears as an apostrophe inside the string instead of terminating the string 39It39s me39 Escaping characters the backslash is used to escape special characters in strings single quote marks 39 double quote marks quot end of line n carriage return r tab t If you want to actually write a backslash you need to escape it with another backslash quotThis is a backslash quotltlt quot This is a backslash quot VARIABLES are a way of storing a value in memory for later use In J avaScript we start by declaring a variable by using the keyword var You can even declare multiple variables at onceRules 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 lower case letter an underscore or dollar symbols It can also contain numbers but cannot start with them name name firstName lastname addressline1 When using multiple words for variable names Camel case starts with a lowercase letter and each new word is then capitalized rstNameAndLastName OR underscore separates each new word with an underscore rstnameandlastname STRING PROPERTIES AND METHODS Properties are information about the object or 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 J avaScript did overcome this by creating wrapper objects for primitive values We access the properties of a string using dot notation This involves writing a dot followed by the property we are interested in For instance 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 Another notation can use to access primitive value39s properties are SQUARE BRACKETS Name39length39 note the property name is in quote marks 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 Name toUpperCase O write a string in all capital letters ltlt quotHEISENBERGquot NametoLowerCase O write names in all lowercase letters ltlt quotheisenbergquot NamecharAt1 which character is at certain position ltlt quotequot NameindexOf quotHquot 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 NamelastIndexOf quotequot want the last occurrence of a character or substring ltlt 7 quotJ avaScriptquotconcat quotNinjaquot concatenate two or more strings together ltlt quotJ avaScriptNinjaquot quotHelloquotconcatquot quot quotWorldquot quotquot ltlt quotHello Worldquot quotJavaquot quotScriptquot quot quot quotNinjaquot A short cut for string concatenation is to use the symbol to add two strings together ltlt quotJ avaScript 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 ltlt quotJ avaScript Ninjaquot NUMBERS Number can be integers or oating point decimals J avaScripts does not distinguish between integers and oating point decimals as they both given the typeof quotnumberquot gt ECMAScript speci cation Also have a constructor function new Number3 NUMBER METHODS toExponential 5 toExponential gtgt quot5e0quot use two dots 5 toExponential gtgt quot5e0quot put a space before the dot 50toExponential gtgt quot5e0quot write integers as a decimal 5 toExponential gtgt quot5e0quot place integers in parentheses Var number 5 gtgt 5 number toExponential gtgt quot5e0quot assign number to 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 of signi cant figures ltlt quot33e 5 quot returned result as a string and use exponential notation ARITHMETIC OPERATIONS Additi Subtracti Multiplicati Division Remaind on on on er of division 5 611 67 37 236 43 ltlt 93 gtgt 5 ltlt 42 04285 ltlt 5 71 CHANGING VARIABLES points 0 initialize points score to zero ltlt 0 points points 10 increase value held in the points var by 10 ltlt 10 points 10 use operator for a shortcut ltlt 20 points 5 decrease points by 5 ltlt 15 points 2 double points lt Var address quot221B Baker Streetquot ltlt unde ned parseIntaddress 10 ltlt 221 the result would return Nan if use Number function Numberaddress ltltNan parseInt would remove anything after the decimal point NOT round number parseIntquot24quot 10 ltlt 2 parseFloat convert string into oating 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 for thisquot NULL means quotno valuequot Undefined and null are both nonvalue values They behave slightly different yet still similar 10 null null behaves like zero ltlt 10 10 undefined unde ned is not a number ltlt Nan Null is coerced to be 0 gt make the possible sum whereas unde ned is coerced to be NaN make the sum impossible to perform Values tend to be set to undefined by J avaScript whereas values are usually set to null manually by the programmer BOOLEANS TRUE AND FALSE 7 values are always false gt falsy values quot quot double quoted empty string 39 39 single quoted empty string 0 Nan False Null undefined BooleanquotHellloquot 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 nd out if a value is truthy or falsy shortcut of Boolean l 39 39 ltlt false quothelloquot ltlt true l l 3 ltlt true ampamp Logical AND the logical AND operator works on 2 or more values and only evaluate to true if ALL the operands are truthy The returned value is the last truthy m if they are all true or the first falsy value if at least one of them is false 3 ampamp 0 returns 0 because it is falsy ltlt 0 Logical OR the OR operator works on two or more operands but evaluates to true I ANY of the operands are true so it only evaluates false if both operands are falsy The returned value is the first truthy value if any of them are true or the last falsy value if all of them are false COMPARISON EQUALITY HARD INEQUALITY GREATER THAN OR LESS THAN If a 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 operator logical OR and a hard equality 8 gt 8 8 quot8quot ltlt false ARRAYS PROPERTIES AND METHODS Pizzaslength find length of array Pizzaspizzaslength1 nd the last item in the array The length property of array is mutable gt can change Pizzaspop remove last item from an array Pizzaspushquotvaluequot 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 Pizzasunshiftquotvaluequot add new to the begginning of the array PizzasconcatquotSpicy Beefquot quotChick and Mushroomsquot 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 nish at the fourth the item with index of 4 is not included This operation is nondestructive no items are actually removed Pizzassplice21 quotChicken and Pepperquot Veggie Deluxequot remove items fron an array and then insert new items in their place ltlt quotPepperoniquot remove the SOFT EQUALITY double equal operator 1tematindex 2 1 item HARD EQUALITY triple equals operator When the soft equality is used J avaScript 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 J avaScript that is not equal to itself NaN NaN ltlt false use function isNaN to test it isNaNNaN ltlt true isNaN does not work properly isNaNquothelloquot ltlt true because function converts string to a number then a string without numerals are converted to NaN gtgt isnan NaN set the 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 Pizzassplice40quotaquot insert quotaquot as the fth item in the pizza array Pizzassplice21 remove the item at index 2 completely without adding Pizzasreverse reverse the order of an array Pizzassort sort the order of array alphabetically PizzasindexOf quotSpicy Beefquot find if a value is in array Ifelse statement If condition code to run if it s true Else code to run if it s false TERNARY OPERATOR Condition code to run if cond Is true code to run if condition isn t true Switch statement could be used when lots of f else statement are string together to make logical decision tree Ater each case statement is the code needs to be run if case occurs It s vital to nish each case block with the break gt Area of Triangle program version 1 I declare three vars for sides of Triangle vars15s26s37 var halfPerim area halfPerim s1 s2 s3 2 area MathsqrthalfPerim halfPerim s1 halfPerim s2 halfPerim s3 consolelogquotarea quot area alertquotarea quot area declare three vars for sides of Triangle var s1 parseIntprompt39enter s139 var s2 parseIntprompt39enter s239 var s3 parseIntprompt39enter s339 var halfPerim area halfPerim s1 s2 s3 2 area MathsqrthalfPerim halfPerim s1 halfPerim s2 halfPerim s3 consolelogquotarea quot area alertquotarea quot area gt Area of a Circle given the radius declare one var for radius of a circle var radius area var r1 parseFloatprompt39enter r1 39 area MathPI Mathsqrtr1 consolelogquotarea quot area alertquotarea quot area Returns the area of a circle with radius r function square r return r r var AOC function radius return MathPI square radius var radius prompt39enter radius39 consolelog AOC 39 AOC radius alert AOC 39 AOC radius gt whether 11 is even function isEven x if x 2 0 return true else return false gt whether it s a vowel var isVowel functionch ch chtoUpperCase if ch 39A39 ll ch 39E39 ch 39139 ch 39039 ch 39U39 return true else return false Amount of a tip where the purchase amount and the tip rate are entered by the user function tipNinj aamtrate return rate amt declare variables var purchaseAmt tipRate tip prompt user for inputs purchaseAmt Numberpromptquotenter purchase amountquot tipRate prompt39enter tipRate39 compute and display results tip tipNinjapurchaseAmt tipRate alertquottip quot tip consolelogquottip quot tip Amount of a tip where the purchase amount and the tip rate are entered by the user var question quotWhat is the value of the billquot var bill promptquestion var result var tip bill 015 consolelogquottip quot tip alertquottip quot tip flipCoin returns 1 for heads or 0 for tails var ipCoin function retur var count 0 count whilecoinFace 0 coinFace ipCoin count consolelogquotHeads Up in quot count quot ipsquot flipC0ins using main function function mainvar target promptquotEnter Heads or Tailsquot var count 0 var coinFace whilecoinFace targetcoinface ipCoinO count consolelogtarget quot up in quot count quot ips quot LOOPS example var arr 23 5 var i 0 loop control variable DISPLAY EACH ELEMENT IN AN ALERT whileilt3 alertarri i alertquotExitingquot var result quotquot first 10 laws of advertising forvar i 1 i lt 10 i consolelogquotRepetitionquot result result i quotzquot quot Repetitionnquot alertresult gt flip two coints until target is hit coinFacel ipCoin coinFace2 ipCoin count cach 2 var done coinFacel target ampamp coinFace2 target while doubles ip two coins until target is hit coinFacel ipCoin coinFace2 ipCoin count ip until coin Doubles whileCoinFace1 target amp coinFace target coinFacel ipCoin coinFace2 ipCoin count gt function getRandornNurnberrnaX var n MathfloorMathrandorn rnaX 1 return gt


Buy Material

Are you sure you want to buy this material for

75 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."

Kyle Maynard Purdue

"When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the I made $280 on 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.