Chapter 1 Flashcards
(49 cards)
Official name for JavaScript
ECMAScript
ECMAScript
A standardized version of javascript that is compatible with various browsers.
//
Single line comments start with //.
Any text between // and the end of the line will be ignored by JavaScript (will not be executed).
/* */
Multi-line comments start with /* and end with */.
Any text between /* and */ will be ignored by JavaScript.
A variable is declared (created) with a
;
Ex. var x;
Describe: x=3+y;
Assigning a value to the variable x
Describe: foo(x,y);
calling function foo with parameters x and y
obj.bar(3)
calling method ‘bar’ of object ‘obj’
conditional statement example
if (x===0) {
return “Try Again”;
}
= vs ===
=== is more strict of an equality
x+=1 equivalent
x=x+1
.length
outputs the number of characters in a variable or value Ex: var str="abc" str.length 3 //output is 3 Ex. "abc".length 3 //output is 3
how to assign a value to a property
you must declare an object, add a property to the object, then assign a value to the property
Ex.
var obj={}; //empty object
obj.foo=123; // create property foo, set it to 123
obj.foo
123 //output is 123
.toUpperCase()
turns precedent characters to all capital letters
“hello”.toUpperCase()
HELLO
can two empty objects be strictly equal to each other
No. Each object has a unique identity and is only strictly equal to itself ex.: var obj1={}; var obj2={}; obj1===obj2 false
string example
“abc”
boolean example
4===2;
false
or 2===2
true
how to add multiple properties to an object
var obj={ firstName: "ayden", lastName: "licea"};
operator for describing the “type” of value
typeof
ex.
typeof true
‘boolean’
or
||
not
!
increment
++ or –
remainder
%
new line
<br></br>
"; } document.getElementById("demo").innerHTML = text; } ``` ``` /*output BMW Volvo Saab Ford Fiat Audi */ ex2 ``` ``` for (let i = 0; i < 4; i++) { document.write(i); } ``` //output = 0123