Essential JavaScript Flashcards
Who developed JavaScript?
Netscape - Brendan Eich
What are some characteristics of JavaScrippt?
High-level scripting language Case-sensitive Intepreted at runtime (JIT compiler) Object base Loosely typed Platform independent Dynamic language (change on the fly)
What is an object?
Self-contained set of related values and functions
What are properties?
Characteristics of an object (e.g. car.color in the object Car
What is a method?
A function that is a property of an object
Some JavaScript flavors?
ECMAScript
TypeScript
Mocha
JScript (Microsoft)
Microsoft intepretation of JavaScript
JScript
What is Node.JS?
Server-side JS
JavaScript interpreters (browser)
Google V8
Spidermonkey (FireFox)
No Script?
Your browser doesn’t support JavaScript
Type attribute?
What are the primitive data types?
String Number Boolean Undefined Null Symbol
Declare a variable
let myNumber = 10;
Expression
myNumber = 10;
Global Scope
Variables declared outside of a code block (use as little as possible)
Local Scope
Any variable using let or const inside a block
Some Keywords?
const let function class null debugger while var typeof indexof
Some reserved words
boolean type catch false float let null this switch true typeof import
What is hoisting?
Hoisting is JavaScript’s default behavior of moving declarations to the top.
A variable has to start with…
A variable name must start with a letter, underscore ( _ ), or dollar sign ( $ ). A variable name cannot start with a number.
What is instantiation?
Process of creating new copies of an object
+= will….?
Add operands and assign value to the left side
Shorthand for: A = A + B
A += B
How to target paretn of all parent files in a frameset?
Use top
How to evaluate multiple custom objects?
Use function
Events trigger?
functions
LiveWire is?
A server-side solution
Methods operate on ….. instances of an object
single
alert, prompt and confirm are methods of….
the window object
Change image on mouseover is an example of…?
the image object
JS object models groups?
3:
browser
language
form fields
!== means..
not equal to
How to clear cookies?
Add expiration date thas has already passed
parsefloat?
converts number to floating point decimal equivalent
Variable is…?
A space of memory
The constructor is….
the building block of all custom objects
Instantiation is..?
create new instances (copies) of the object (once constructor has been defined)
Do all browser store cookies the same way?
No
A sentence on the page (in JS) is an example of..?
An object
Types of expressions allowed in JS?
Assignment
Arithmetic
String
Logical
Insert a new line
\n
What are the event handlers on the select-object?
onBlur
onFocus
onChange
Operators are used in expressions to…
store or return a value
Instance
real-time objects generated from the empty constructor template
What is the main event handler of the button object?
onClick
Literals are..?
the actual data values you provide in JS
Logical AND
&&
Logical OR
||
Variables can store … date types
5
A constructor..
creates an empty template from which real-time objecst, called instances, can be created
Language objects:
string
array
date
math
The continue statement can only be used in..
A for or while loop
Some properties of the document object
alinkColor bgColor cookie fgColor createElement createEvent getElementsById getElementsByClassName querySelectorAll
Reflect information on browser being used?
Use the navigator object. Brand + version of the browser + users operating system
The method toUpperCase() can also be called a function
True
Most common and functionel use of client side JS?
Validate form field submissions
When alert and prompt are both used in the same statement the….
prompt method will process first
To instantiate and then populate the properties of each new instance with actual date, you must…
declare variables
In order to target a frame, you need to know..
A frame’s number in the frames array, or the frame’s name
JavaScript is an object … programming language
based
How to test the presence of cookie?
alert(document.cookie);
The … method allows you to create text that is dynamically written to the window
document.write()
Targets the parent of all parents in a frameset?
top
An argument is…
a value or expression containing data or code that is passed on to a function or procedure
What would this return? “Sandy Cobb”.charAt(3);
D
Index starting at 1 for strings!
! Returns -1 if the value is not found !
The document.write method belongs to the …. object
document
You must declare variables that will become object references to a newly instantiated objects to…
instantiate and then populate the properties of each new instance with actual data
What is the main event handler for a checkbox?
onClick
How to appropriate syntax for accessing a function stored in a frame file?
relationship.frameName.functionName();
alert, prompt adn confirm are examples of…
methods
An expression is…
a part of a statement that is evaluated as a value
One domain cannot deposit a cookie for another domain. This would be cross-domain posting and in theroy, is not possible. However, the cross-domain posting rule can be bypassed with the use of shared cookies
True
The window object is subordinate to the document object in the JavaScript hierarchy.
False
How to retrieve MIME? Multipurpose Internet Mail Extensions
Use encoding (propertie of the form object)
A break statement can be used within the…
for and while loops
Max size for cookie header?
4 kb
-= is a …. type of operator
assignment
Constructor = ….
A function that defines methods and properties of a custom object used as a template for instances of the custom object
How to change two frames simultaneaously in JS?
Write a function that inclused two or more location.href statements
The first character of a variable must be a letter or an underscore, but subsequent characters can be letters, numbers, and the underscore character.
True
Which information is required to generate a cookie?
The nam=value pair is the only required information
What is a fundamentel problem with JS web sites?
Scripts can generate security problems or infinite loops IF written incorrectly
Which action can be performed by an object?
Method
Example how to escapte quotations marks..
var ssingleQ = 'It\'s nine o\' clock in the morning.'; var doubleQ = "Mukesh Ambani is \"the richest man\" of India.";
When using frames, where should functions and variables be stored in a JavaScript-based Web site?
In any HTML file that is invoked in making the frameset
Consider the following HTML: <tt></tt> Which method of the String object is used to write the JavaScript equivalent to this HTML?
fixed()
In which part of the HTTP communication protocol does the cookie initially begin to function?
in the HTTP response header
Consider the following HTML: Which method of the String object is used to write the JavaScript equivalent to this HTML?
italic()
Which property of the form object is a string value that contains the name of the window or frame to which responses to form submissions are directed?
target
Which JavaScript object should be used to create buttons that animate whenever the mouse pointer passes over them?
image
Which property of the document object represents the color in which text is to be displayed?
fgColor
Which string value contains the name of the client used to access a page under the navigator object (i.e., Netscape for Netscape Navigator)?
AppName
Which property of the location object refers to the hostname:port solution of the URL?
host
Which method of the String object would you use when writing the name of a chemical compound, such as “H20”?
sub()
What is a constructor function in JavaScript?
A special function that allows the construction of object s
Which property of the form object describes the URL to which the form data is submitted?
action
What is the primary difference between method and functions when working with custom JavaScript objects?
Methods work with single instances of objects. Functions can work on all instances of an object
Describe JavaScript
Interpret at run time, and NOT compiled
Nadir has created several new instances of custom objects. How can he now allow access to this information with a Web browser?
He must create an object method that allows the viewing of the object
Which property of the form object represents the identity of the form as defined in the tag?
name
Which method of the String object would you use when writing a complex mathematical formula in JavaScript that includes powers, such as “E=MC2”?
small()
Can a cookie identify a user to a Web site even if that user has never submitted personal information to that site?
Only if the user visited a site that uses shared cookies
Which property of the location object specifies the internal link anchor name, which is followed by the number sign (#) in the URL?
hash
Tanja needs to examine only a small portion of a string. Which JavaScript method should she use to perform this task?
substring()
Describe how cookies are stored on a user’s hard drive?
Depending on the browser type, cookies are stored as text strings in directories
Can the practice of calling JavaScript functions from framesets be extended to calling them from different browser windows?
yes
When using custom JavaScript objects, why should you use arrays of instantiate each object individually?
Arrays are more flexible and indexed thus repetitive tasks are easier to handle
Which is the JavaScript property that is used to inform a script that an image has finished loading?
complete
Which property of the navigator object identifies the operating system for which the browser was compiled?
userAgent
Can a programmer refer to a variable from anywhere in a frameset?
Yes
Term for a single line of JavaScript code that is executed in a script or program?
statement
How many cookies are permitted per domain on a user’s hard drive?
Twenty cookies per domain
Which special character in JavaScript is interpreted as a tab?
\t
In JavaScript, objects possess?
properties and methods
Several different types of JavaScript objects exist, such as String, Math, Array, and Date. What are these types of objects called?
language
Which property of the location object specifies the full URL of a file or site?
href
Wilhelm is writing a constructor in JavaScript. He uses the word “this” when referring to the properties and methods in his object parameters and functions. Why?
The this keyword is used to represent the object as the properties and methods are defined
Which property of the location object specifies whether HTTP or FTP is being used?
protocol
What is the JavaScript term for a string value that represents the URL of the document from which the current document was accessed?
referrer
In Microsoft Internet Explorer, what is the purpose of the DAT file?
The DAT file is used in caching, sometimes in tandem with cookies.txt
If no element exists (using the getElementById) what is the return?
null
Whitespaces are treated as…. (DOM)
text node
Some methods of the history object (window.history)
history. back() - same as clicking back in the browser
history. forward() - same as clicking forward in the browser