Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
133 Cards in this Set
- Front
- Back
Name all the javascript string functions
|
1. charAt
2. charCodeAt 3. concat 4. fromCharCode 5. indexOf 6. lastIndexOf 7. match 8. replace 9. search 10. slice 11. split 12. substr 13. substring 14. toLowerCase 15. toUpperCase |
|
charAt()
|
Returns the character at the "x" position within the string.
|
|
charCodeAt(x)
|
Returns the Unicode value of the character at position "x" within the string.
|
|
concat(v1, v2,...)
|
Combines one or more strings (arguments v1, v2 etc) into the existing one and returns the combined string. Original string is not modified.
|
|
fromCharCode(c1, c2,...)
|
Returns a string created by using the specified sequence of Unicode values (arguments c1, c2 etc). Method of String object, not String instance. For example: String.fromCharCode().
|
|
indexOf(substr, [start])
|
Searches and (if found) returns the index number of the searched character or substring within the string. If not found, -1 is returned. "Start" is an optional argument specifying the position within string to begin the search. Default is 0.
|
|
lastIndexOf(substr, [start])
|
Searches and (if found) returns the index number of the searched character or substring within the string. Searches the string from end to beginning. If not found, -1 is returned. "Start" is an optional argument specifying the position within string to begin the search. Default is string.length-1.
|
|
match(regexp)
|
Executes a search for a match within a string based on a regular expression. It returns an array of information or null if no match is found.
|
|
replace( regexp, replacetext)
|
Searches and replaces the regular expression portion (match) with the replaced text instead.
|
|
search(regexp)
|
Tests for a match in a string. It returns the index of the match, or -1 if not found.
|
|
slice(start, [end])
|
Returns a substring of the string based on the "start" and "end" index arguments, NOT including the "end" index itself. "End" is optional, and if none is specified, the slice includes all characters from "start" to end of string.
|
|
split(delimiter, [limit])
|
Splits a string into many according to the specified delimiter, and returns an array containing each element. The optional "limit" is an integer that lets you specify the maximum number of elements to return.
|
|
substr(start, [length])
|
Returns the characters in a string beginning at "start" and through the specified number of characters, "length". "Length" is optional, and if omitted, up to the end of the string is assumed.
|
|
substring(from, [to])
|
Returns the characters in a string between "from" and "to" indexes, NOT including "to" inself. "To" is optional, and if omitted, up to the end of the string is assumed.
|
|
toLowerCase()
|
Returns the string with all of its characters converted to lowercase.
|
|
toUpperCase()
|
Returns the string with all of its characters converted to uppercase.
|
|
valueOf
|
Returns the primitive value of a String object
|
|
How would you make a singleton in js
|
var Singleton =(function(){
var instantiated; function init (){ // all singleton code goes here return { publicWhatever:function(){ alert('whatever') }, publicProperty:2 } } return { getInstance :function(){ if (!instantiated){ instantiated = init(); } return instantiated; } } })() //to call public methods now use: Singleton.getInstance().publicWhatever(); |
|
factory method in js
|
factory = function(){
return{ name: "Ezell", getName : function(){ return this.name; } } } |
|
synchronus AJAX request in javascript using GET
|
var xhr = new XMLHttpRequest();
xhr.open("GET", "textfile.txt", false); xhr.send(null); alert(xhr.responseText) |
|
Asynchronus request with get
|
var xhr = new XMLHttpRequest();
xhr.open("GET", "textfile.txt", false); xhr.onreadystatechange = function(){ if(xhr.readyState === 4){ if((xhr.status >= 200 && xhr.status < 300) && status === 304){ alert(xhr(responseText) }else{ alert("something bad happened") } alert(xhr.responseText); } } xhr.send(null); |
|
the difference between the constructor function and the factory method
|
The difference between the constructor function and the factory method is the constructor makes an datatype and the factory only makes a object
|
|
describe error handling in js
|
try{
alert("this code will not fail"); abert("this code will fail"); alert("this code will not excute"); }catch{ alert("an error occured. This will run when something in the try block fails"); }finally{ alert("this will always run") } |
|
How would use the xhr technology with the post request
|
var xhr = new XMLHttpRequest();
xhr.open("POST", "textfile.txt", true); var data = getRequestBody(); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded") xhr.onreadystatechange = function(){ if(xhr.readyState === 4){ if((xhr.status >= 200 && xhr.status < 300) && status === 304){ alert(xhr(responseText) }else{ alert("something bad happened") } alert(xhr.responseText); } } xhr.send(data); var getRequestBody = function(){ var form = document.getElementById(); } |
|
primitive values in js
|
String
Number Boolean Undefined Null |
|
Reference types in js
|
Object
Array function Date RegExp |
|
how can you force garbage collector?
|
make a primitive
|
|
create a person object with object literal notation
|
var Person{
firstName: "Ezell", lastName : "Burke", getWholeName : function(){ console.log("Hello my name is "+firstName+" "+lastName+"."); } } |
|
What are the parameters to Object.define Property?
|
1. the object the property beliongs to.
2. the name of the property string value 3. object called the descirptor object- defines the options we will set on the property -data descriptors -accessor descriptors |
|
describe Object.defineProperty
|
This method allows precise addition to or modification of a property on an object.
|
|
Property descriptors
|
Property descriptors present in objects come in two main flavors: data descriptors and accessor descriptors.
|
|
data descriptors
|
A data descriptor is a property that has a value, which may or may not be writable.
|
|
accessor descriptor
|
An accessor descriptor is a property described by a getter-setter pair of functions.
|
|
what keys do the property descriptors share?
|
Both data and accessor descriptors are objects. They share the following optional keys:
1. configurable true if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. Defaults to false. 2. enumerable true if and only if this property shows up during enumeration of the properties on the corresponding object. Defaults to false. |
|
What are the optional keys for data descriptors?
|
A data descriptor also has the following optional keys:
1. value The value associated with the property. Can be any valid JavaScript value (number, object, function, etc) Defaults to undefined. 2. writable True if and only if the value associated with the property may be changed with an assignment operator. Defaults to false. |
|
What are the optional keys for accesor descriptor?
|
An accessor descriptor also has the following optional keys:
1. get A function which serves as a getter for the property, or undefined if there is no getter. The function return will be used as the value of property. Defaults to undefined. 2. set A function which serves as a setter for the property, or undefined if there is no setter. The function will receive as only argument the new value being assigned to the property. Defaults to undefined. |
|
When should you use a constructor function?
|
Use a constructor function when you need more than one of the same type of object otherwise use an object literal.
|
|
Example of a constructor function.
|
var Person = function(firstName, lastName){
this.firstName = firstName; this.lastName = lastName; Object.defineProperty(this, "fullName", { get : function(){ return this.firstName + " " + this.lastName; } }); //define method in Prototype Person.prototype.sayHi = function(){ return "Hi there." } } var Person = new Person('Ezell', 'Burke'); |
|
When should you use hasOwnProperty method
|
Use the hasOwnProperty() method to differentiate between own properties and prototype properties.
|
|
What should you do when you completly overwrite a prototype?
|
You should reset the constructors of the prototypes:
Person.prototype.constructor = Person; |
|
javascript global functions
|
1. decodeURI
2. decodeURiComponent 3. encodeURI 4. escape 5. eval 6. isFinite 7. isNaN 8. Number 9. parseFloat 10. parseInt 11. String 12. unescape |
|
encodeURI()
|
This function encodes special characters, except: , / ? : @ & = + $ # (Use encodeURIComponent() to encode these characters).
|
|
encodeURIComponent()
|
The encodeURIComponent() function encodes a URI component.
|
|
escape()
|
The escape() function encodes a string.
|
|
eval()
|
The eval() function evaluates or executes an argument.
|
|
isFinite
|
The isFinite() function determines whether a number is a finite, legal number.
Tip: This function returns false if the value is +infinity, -infinity, or NaN. |
|
isNaN()
|
The isNaN() function determines whether a value is an illegal number (Not-a-Number).
|
|
Number()
|
The Number() function converts the object argument to a number that represents the object's value.
|
|
parseFloat();
|
The parseFloat() function parses a string and returns a floating point number.
|
|
parseInt(string, rasdix)
|
The parseInt() function parses a string and returns an integer.
The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number. If the radix parameter is omitted, JavaScript assumes the following: If the string begins with "0x", the radix is 16 (hexadecimal) If the string begins with "0", the radix is 8 (octal). This feature is deprecated If the string begins with any other value, the radix is 10 (decimal) |
|
String()
|
The String() function converts the value of an object to a string.
|
|
unescape(string)
|
The unescape() function decodes an encoded string.
|
|
What are the window Object Properties?
|
1. closed
2. defaultStatus 3. document 4. frames 5. history 6. innerHeight 7. innerWidth 8. length 9. location 10. name 11. navigator 12. opener 13. outerWidth 14. outerHeight 15. pageXOffset 16. pageYOffset 17. parent 18. screen 19. screenLeft 20. screenTop 21. screenX 22. screenY 23. self 24. status 25. top |
|
window.closed()
|
Returns a Boolean value indicating whether a window has been closed or not
|
|
window.defaultStatus
|
The defaultStatus property sets or returns the default text in the status bar at the bottom of the browser (the text will be displayed when the page loads).
example: window.defaultStatus="This is the default text in the status bar!!" Note: The defaultStatus property does not work in the default configuration of IE, Firefox, Chrome, or Safari. To allow scripts to change the text of the status, the user must set the dom.disable_window_status_change preference to false in the about:config screen. (or in Firefox: "Tools - Options - Content -Enable JavaScript / Advanced - Allow scripts to change status bar text"). |
|
window.document
|
Returns the Document object for the window
|
|
window.frames
|
Returns an array of all the frames (including iframes) in the current window
|
|
window.history
|
Returns the History object for the window
|
|
window.innerHeight
|
Sets or returns the inner height of a window's content area
|
|
window.innerWidth
|
Sets or returns the inner height of a window's content area
|
|
window.length
|
Returns the number of frames (including iframes) in a window
|
|
window.location
|
returns the location object
|
|
window.name
|
sets or returns the name of the window
|
|
window.navigator
|
Returns the navigator object for the window
|
|
window.opener
|
Returns the reference to the window that created the window
|
|
window.outWidth
|
Sets or returns the outer width of a window, including toolbars/scrollbars
|
|
window.pageXOffset
|
Returns the pixels the current document has been scrolled (horizontally) from the upper left corner of the window
|
|
window.pageYOffset
|
Returns the pixels the current document has been scrolled (vertically) from the upper left corner of the window
|
|
window.parent
|
Returns the parent window of the current window
|
|
window.screen
|
Returns the Screen object for the window (See Screen object)
|
|
window.screenLeft
|
Returns the x coordinate of the window relative to the screen
|
|
window.screenY
|
Returns the y coordinate of the window relative to the screen
|
|
window.outerHeight
|
Sets or returns the outer height of the window including toolbars /scrollbars
|
|
window.screenTop
|
Returns the y coordinate of the window relative to the screen
|
|
window.screenY
|
Returns the y coordinate of the window relative to the screen
|
|
window.self
|
Returns the current window
|
|
window.status
|
Sets the text in the statusbar of a window
|
|
window.top
|
returns the topmost browser window
|
|
what are the window object methods?
|
1. alert
2. blur 3. clearInterval 4. clearTimeout 5. close 6. createPopup 7. focus 8. moveBy 9. moveTo 10 open 11. print 12. prompt 13. resizeBy 14. resizeTo 15. scroll 16. scrollBy 17. scrollTo 18. setInterval 19. setTimeout |
|
window.blur()
|
The blur() method removes focus from the current window.
The blur() method is supported in all major browsers, except Opera. |
|
window.clearInterval
|
The clearInterval() method clears a timer set with the setInterval() method.
The ID value returned by setInterval() is used as the parameter for the clearInterval() method. Syntax clearInterval(id_of_setinterval) |
|
window.clearTimeout()
|
The clearTimeout() method clears a timer set with the setTimeout() method.
|
|
window.confirm()
|
Definition and Usage
The confirm() method displays a dialog box with a specified message, along with an OK and a Cancel button. This method returns true if the visitor clicked "OK", and false otherwise. Syntax confirm(message) Browser Support The confirm() method is supported in all major browsers. |
|
window.createPopup()
|
Window createPopup() Method
Definition and Usage The createPopup() method is used to create a pop-up window. Syntax window.createPopup() Browser Support Note: The createPopup() method is an IE-only method, and does not work in other browsers! |
|
window.focus()
|
Definition and Usage
The focus() method sets focus to the current window. Syntax window.focus() Browser Support The focus() method is supported in all major browsers. |
|
window.moveBy()
|
Definition and Usage
The moveBy() method moves a window a specified number of pixels relative to its current coordinates. Syntax window.moveBy(x,y) Browser Support The moveBy() method is supported in all major browsers. |
|
window.moveTo(x,y)
|
Definition and Usage
The moveTo() method moves a window's left and top edge to the specified coordinates. Syntax window.moveTo(x,y) Browser Support The moveTo() method is supported in all major browsers. Note: Specifying moveTo(0,0) in Opera, results in moving the window to the top left corner of the browser, not the screen. |
|
window.open()
|
Definition and Usage
The open() method opens a new browser window. Syntax window.open(URL,name,specs,replace) Browser Support The open() method is supported in all major browsers. |
|
Describe the first parameter of the window.open function
|
url : Optional. Specifies the URL of the page to open. If no URL is specified, a new window with about:blank is opened
|
|
Describe the second parameter of the window.open function
|
name: Optional. Specifies the target attribute or the name of the window. The following values are supported:
_blank - URL is loaded into a new window. This is default _parent - URL is loaded into the parent frame _self - URL replaces the current page _top - URL replaces any framesets that may be loaded name - The name of the window |
|
Describe the third parameter of the window.open function
|
specs - A comma-separated list of items.
the items are 1.channel 2. directories 3. fullscreen 4. height 5. left 6. location 7. menubar 8. resizeable 9. scrollbars 10. titlebar 11. toolbar 12. top 13. width |
|
Describe the fourth parameter of the window.open function
|
replace Optional.Specifies whether the URL creates a new entry or replaces the current entry in the history list. The following values are supported:
true - URL replaces the current document in the history list false - URL creates a new entry in the history list |
|
window.print()
|
Definition and Usage
The print() method prints the contents of the current window. Syntax window.print() Browser Support The print() method is supported in all major browsers. |
|
window.setInterval()
|
Definition and Usage
The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds). The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed. The ID value returned by setInterval() is used as the parameter for the clearInterval() method. Tip: 1000 ms = 1 second. Syntax setInterval(code,millisec,lang) Parameter Description code Required. The function that will be executed millisec Required. The intervals (in milliseconds) on how often to execute the code lang Optional. JScript | VBScript | JavaScript Browser Support The setInterval() method is supported in all major browsers. |
|
Properties of the location object
|
1. hash
2. host 3. hostname 4. href 5. pathname 6. port 7. protocol 8. search |
|
location.hash
|
Definition and Usage
The hash property returns the anchor portion of a URL, including the hash sign (#). Syntax location.hash Browser Support The hash property is supported in all major browsers. |
|
location.host
|
Definition and Usage
The host property returns the hostname and port of a URL. Syntax location.host Browser Support The host property is supported in all major browsers. |
|
location.hostname
|
Definition and Usage
The host property returns the hostname of a URL. Syntax location.hostname Browser Support The hostname property is supported in all major browsers. |
|
location.href
|
Definition and Usage
The href property returns the entire URL of the current page. Syntax location.href Browser Support The href property is supported in all major browsers. |
|
location.pathname
|
Definition and Usage
The pathname property returns the path name of a URL. Syntax location.pathname Browser Support The pathname property is supported in all major browsers. |
|
location.port
|
Definition and Usage
The port property returns the port number the server uses for a URL. Note: If the port number is 80 (which is the default port number), it is not specified. Syntax location.port Browser Support The port property is supported in all major browsers. |
|
location.protocol
|
Definition and Usage
The protocol property returns the protocol of the current URL, including the first colon (:). Syntax location.protocol Browser Support The protocol property is supported in all major browsers. |
|
location.search
|
Definition and Usage
The search property returns the query portion of a URL, including the question mark (?). Syntax location.search Browser Support The search property is supported in all major browsers. |
|
What are the location object methods
|
1. assign
2. reload 3. replace |
|
location.assign(URL)
|
Definition and Usage
The assign() method loads a new document. Syntax location.assign(URL) Browser Support The assign() method is supported in all major browsers. |
|
location.reload()
|
Definition and Usage
The reload() method is used to reload the current document. The reload() method does the same as the reload button in your browser. By default, the reload() method reloads from the cache, but by you can force the the reload to get the page from server by setting the forceGet parameter to true. Browser Support The reload() method is supported in all major browsers. |
|
location.replace(newURL)
|
Definition and Usage
The replace() method replaces the current document with a new one. Syntax location.replace(newURL) Browser Support The replace() method is supported in all major browsers. |
|
What are the Navigator properties
|
1. appCodeName
2. appName 3. appVersion 4. cookieEnabled 5. onLine 6. platform 7. userAgent |
|
navigator.appCodeName
|
Definition and Usage
The appCodeName property returns the code name of the browser. Syntax navigator.appCodeName Browser Support The appCodeName property is supported in all major browsers. |
|
navigator.appName
|
Definition and Usage
The appName property returns the name of the browser. Syntax navigator.appName Browser Support The appName property is supported in all major browsers. |
|
navigator.appVersion
|
Definition and Usage
The appVersion property returns the version information of the browser. Syntax navigator.appVersion Browser Support The appVersion property is supported in all major browsers. |
|
navigator.cookieEnabled
|
Definition and Usage
The cookieEnabled property returns a Boolean value that specifies whether cookies are enabled in the browser. Syntax navigator.cookieEnabled Browser Support The cookieEnabled property is supported in all major browsers. |
|
navigator.onLine
|
Definition and Usage
The onLine property returns a Boolean value that specifies whether the system is in offline mode. Syntax navigator.onLine Browser Support The onLine property is supported in all major browsers. |
|
navigator.platform
|
Definition and Usage
The platform property returns for which platform the browser is compiled. Syntax navigator.platform Browser Support The platform property is supported in all major browsers. |
|
navigator.userAgent
|
Definition and Usage
The userAgent property returns the value of the user-agent header sent by the browser to the server. Syntax navigator.userAgent Browser Support The userAgent property is supported in all major browsers. |
|
What are the Navigator Object Methods?
|
1. javaEnabled
2. taintEnabled |
|
navigator.javaEnabled()
|
Definition and Usage
The javaEnabled() method returns a Boolean value that specifies whether the browser has Java enabled. Syntax navigator.javaEnabled() Browser Support The javaEnabled() method is supported in all major browsers. |
|
navigator.taintEnabled()
|
Definition and Usage
The taintEnabled() method returns a Boolean value that specifies whether the browser has data tainting enabled. Syntax navigator.taintEnabled() Browser Support The taintEnabled() method is supported in Internet Explorer and Opera. |
|
What are the Screen Object properties?
|
1. availHeight
2. availWidth 3. colorDepth 4. height 5. width 6. pixelDepth |
|
screen.availHeight
|
Definition and Usage
The availHeight property returns the height of the visitor's screen, in pixels, minus interface features like the Windows Taskbar. Syntax screen.availHeight Browser Support The availHeight property is supported in all major browsers. |
|
screen.availWidth
|
Definition and Usage
The availWidth property returns the width of the visitor's screen, in pixels, minus interface features like the Windows Taskbar. Syntax screen.availWidth Browser Support The availWidth property is supported in all major browsers. |
|
screen.colorDepth
|
Definition and Usage
The colorDepth property returns the bit depth of the color palette for displaying images (in bits per pixel). Syntax screen.colorDepth Browser Support The colorDepth property is supported in all major browsers. |
|
screen.height
|
Definition and Usage
The height property returns the total height of the visitor's screen, in pixels. Syntax screen.height Browser Support The height property is supported in all major browsers. |
|
screen.pixelDepth
|
Definition and Usage
The pixelDepth property returns the color resolution (in bits per pixel) of the visitor's screen. Syntax screen.pixelDepth Browser Support The pixelDepth property is supported in all major browsers, except Internet Explorer. Tip: The colorDepth property represents the same thing as the pixelDepth property. Since all major browsers support colorDepth, use that property instead. |
|
screen.width
|
Definition and Usage
The width property returns the total width of the visitor's screen, in pixels. Syntax screen.width Browser Support The width property is supported in all major browsers. |
|
window.setTimeout()
|
Definition and Usage
The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds. Tip: 1000 ms = 1 second. Syntax setTimeout(code,millisec,lang) Parameter Description code Required. The function that will be executed millisec Required. The number of milliseconds to wait before executing the code lang Optional. The scripting language: JScript | VBScript | JavaScript Browser Support The setTimeout() method is supported in all major browsers. |
|
What are the methods for the screen object?
|
there are none
|
|
What are the properties for the history object
|
length
|
|
history.length
|
Definition and Usage
The length property returns the number of URLs in the history list. Note: Internet Explorer and Opera start at 0, while Firefox, Chrome, and Safari start at 1. Syntax history.length Browser Support The length property is supported in all major browsers. |
|
What are the methods for the history object?
|
1. back
2. forward 3. go |
|
history.back()
|
Definition and Usage
The back() method loads the previous URL in the history list. This is the same as clicking the Back button or history.go(-1). Syntax history.back() Browser Support The back() method is supported in all major browsers. |
|
history.forward()
|
Definition and Usage
The forward() method loads the next URL in the history list. This is the same as clicking the Forward button or history.go(1). Syntax history.forward() Browser Support The forward() method is supported in all major browsers. |
|
history.go()
|
Definition and Usage
The go() method loads a specific URL from the history list. The parameter can either be a number which goes to the URL within the specific position (-1 goes back one page, 1 goes forward one page), or a string. The string must be a partial or full URL, and the function will go to the first URL that matches the string. Syntax history.go(number|URL) Browser Support The go() method is supported in all major browsers. |