Terms Flashcards
What type of language is JavaScript?
It is a scripting language.
JavaScript is a scripting language. What is a scripting language?
A scripting language is a lightweight programming language.
What would be the result of the following code?
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
It will write what is between the <h1> and <p> tags to the browser screen formated accordingly to the respective HTML tags
What happens is you use:
document.write
After the document has loaded?
The whole document will be overwritten. Only use in the HTML output.
The alert() function is not much used in JavaScript, however it is useful for…?
It is often quite handy for trying out code.
What will this code do?
<p>
JavaScript can change the content of an HTML element.
</p>
It will change the text between the <p> tags to the content in quotes after x.innerHTML
Hello JavaScript!
This piece of code tells the computer to do what?
x=document.getElementById(“demo”);
Find the Element
(“demo”);
document.getElementById(“some id”)
The “Id” could be anything else.
This piece of code tells the computer to do what?
x.innerHTML=”Hello JavaScript!”;
Change the content of the x variable to Hello JavaScript!
What is the difference between JavaScript and Java ?
They are two completely different languages, in both concept and design.
Java (invented by Sun) is a more complex programming language in the same category as C.
What is the official name of the JavaScript standard ?
ECMA-262
Who invented JavaScript ?
Brendan Eich
In what year and what browser did JavaScript first appear ?
1995
In what year did the ECMA (a standard association) adopt JavaScript ?
1997
Who is the ECMA ?
European Computer Manufacturers Association
now the ECMA International
In an HTML document JavaScript must be placed between which tag ?
In what section of an HTML document can JavaScript be placed ?
The or the sections.
JavaScript can be placed in which part(s) of an HTML document ?
The or the sections.
It is common practice to place all JavaScript where in an HTML document ?
All in the section or at the end of the section, this way it is all in one place and does not interfere with the page content.
What does the following code do?
<!DOCTYPE html>
Links the “myScript.js” JavaScript file to the HTML document. Example of an External JavaScript file.
Is there something wrong with this file named:
myScript.js
External scripts cannot contain
What is JavaScript typically used for in regard to HTML documents ?
To manipulate HTML elements.
How do you access an HTML element from JavaScript
and what attribute do you use in the HTML?
To use the document.getElementById(“id”) method.
Use the id=” “ attribute to identify the HTML element:
JavaScript is a sequence of __________ to be executed by the browser.
statements
JavaScript statements are ________ to the browser.
commands
What is at the end of all JavaScript statements to separate each one from the next?
A semicolon ;
Is the semicolon at the end of each statement necessary?
No, it’s optional
JavaScript statements are grouped together in ______.
blocks
Blocks of JavaScript start and end with what?
Start with a left curly bracket and end with a right curly bracket.
Ex.
{
statement;
statement;
}
What is the purpose of grouping JavaScript statements together in blocks?
So that they execute together.
Is JavaScript case sensitive?
Yes
Ex.
getElementById is not the same as getElementbyId (the first one is correct)
Which one is correct:
var name="Hege"; var name = "Hege";
Both… JavaScript ignores extra spaces. You can add white space to your script to make it more readable.
You can break up a code line within a text string using what?
A backslash \
Ex.
document.write(“Hello \
World!”);
What is the difference in how a scripting language (JavaScript) is executed verses how a traditional programming language is executed?
Scripting code is executed line by line while the browser reads it. With traditional programming, all the code has to be compiled before it can be executed.
How do you insert a single line comment in JavaScript?
Two forward slashes
Ex.
// This is a single line comment
// This is another one
How do you insert a multi-line comment in JavaScript?
Comment starts with a forward slash and an asterisk and ends with an asterisk and a forward slash.
Ex.
/* This is an example of a multi-line comment as it should be formated in JavaScript code. */
Why would you use comments to prevent certian lines of code or statements from being executed?
Can be useful for debugging.
Think of variables as __________ for storing data.
containers
Variable can have shortVariable can have short names (like x and y) or more descriptive names (age, sum, totalvolume).
True
True or False
Variable names can begin with a letter or a number.
False
Variable names must begin with a letter.
Besides a letter, variable names can begin with what two symbols
Variable names can also begin with $ and _
Are JavaScript variables case sensitive?
Yes
Variable names are case sensitive (y and Y are different variables)
Besides numbers JavaScript variable can also hold ________.
Other types of data, like text values (name=”John Doe”).
In JavaScript a text variable like “John Doe” is called a ______.
string
When you assign a text value to a variable what do you put around it?
Single or double quotation marks.
Ex.
var name=’john doe’
OR
var name2=”jane doe”
Creating a variable in JavaScript is most often referred to as _________ a variable.
declaring
What keyword do you use in JavaScript to declare a variable?
The var keyword.
Ex.
var name=”john doe”;
What is the case if you declare a variable with no value?
Ex.
var carname;
The variable is empty
It’s a good programming practice to declare all the variables where?
All in one place at the beginning of your code.
You can declare multiple variables in one statement separated by what?
A comma
Ex.
var name=”Doe”, age=30, job=”carpenter”;
OR Multi-line
var name="Doe", age=30, job="carpenter";
Variables declared without a value will have the value _________.
undefined
Undefined or empty variables may receive a value later by what means.
The result of a calculation or user input.