IES: JS-deck 2 Flashcards

1
Q

JS function

A
  • JS is case-sensitive
  • Typically, expressions may be enclosed in ()
  • JS coding may include keywords, operators, values -fixed and variable-, and expressions -which are basically a mix of all, sometimes, and may equal a single value.
  • JS explanatory comments may be added in specific fashion
  • For consistency, stick with either (‘) or (“) with string literals in your code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

JS explanatory comments

A
  • “comment-out” lines of code to prevent their execution when debugging code
  • shootCharacter sequences may be placed in code without execution: following a “//” (on the same line) or between “/*” and “*/” (for one or more lines)
  • when comment-out coding is used, included character sequences are ignored by any code reader
  • Good practice: adding explanatory comments makes your JS code more understandable to others as well as yourself, later
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

JS “abstract”

A
  • JS does not have a built-in abstract keyword
  • JS significant: avoid in variable/function names
  • In JavaScript, there is no abstract keyword
  • JS: achieved using abstract classes & interfaces.
  • fundamental concept in object-oriented programming (OOP)
  • hiding the implementation details of an object and exposing only the essential features
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

JS “arguments”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Represents the list of parameters passed to the function when calling the function.
  • Example
const func = function(p1, p2, p3) {
const param = Array.from(arguments);
console.log(param) // [11, 22, 33]
}
func(11, 22, 33);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

JS “await”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used to wait for javascript until the Promise returns its result.
  • Ex’s.
    1.)
async function fun() {
let promise = new Promise((resolve, reject) => {
setTimeout(() => resolve(" yes, it is done!"), 100)
});

2.)

let res = await promise; // wait until the promise returns us a value
alert(result); // output give yes, it is done
}
};
fun();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

JS “boolean”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • JS represents a data type that can have one of two values: true or false.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

JS “break”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • used into a loop to break or stop the execution of the loop.
  • Example
for(var a=0; a<=10; a++) {
if(a == 5)
break;
document.write("The loop is running for " + a + " times");
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

JS “byte”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • JS: a group of 8 bits. A bit is the most basic unit and can be either 1 or 0
  • not just 8 values between 0 and 1, but 256 (2 to the 8th power)) different combinations (rather permutations) ranging from 00000000 via e.g. 01010101 to 11111111 . Thus, one byte can represent a decimal number between 0(00) and 255.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

JS “case”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used in a switch-case construct, where the value of an expression compares with the case clause value and executes the statements associated with the case whose case value is matched.
  • Example
var date = new Date();
switch(date.getDay()) {
case 6:
alert("This is weekend.");
break;
case 0:
alert("This is weekend.");
default:
alert("Looking for a weekend.");
break;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

JS “catch”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Again used in exception handling to handle the error.
  • Example
Var i=1
try {
if(i == "") throw "is Empty";
if(x > 0) throw "positive";
if(x < 0) throw "negative";
}
catch(msg) {
message.innerHTML = " Input " + msg;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

JS “char”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • reserved keyword in JavaScript that is reserved for “future” use.
  • JavaScript doesn’t have a dedicated char data type.
  • JS uses string data type for single characters and character sequences
  • Strings in JavaScript are immutable: Once created, cannot be modified
  • Examples
    1. Access character in a string using its index, which starts from 0
let str = "Hello";
let firstChar = str[0]; // firstChar will be 'H'

OR
2. Create a string containing a single character using single or double quotes.

let singleChar = 'a'; 
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

JS “class*”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used to define a class.
  • Example
public class Employee {
public String efn = "Joseph";
public String eln = "Doe";
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

JS “const”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used to define a constant variable and that cannot be farther reassigned.
  • Example
    const age=22;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

JS “continue”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used into a loop to continue the loop and skip the following statements inside the loop.
  • Example
for(var a=0; a<=10; a++) {
if(a == 5)
continue;
document.write("The loop is running for " + a + " times");
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

JS “debugger”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used to stop the execution of javascript code and call debugging function if define. Debugger keyword word the same as the break.
  • Example
var prod = 10 * 10;
debugger;
document.getElementbyId("id").innerHTML = prod;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

JS “default”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used in a switch expression to specify the actions to be performed if no case
  • Example
var date = new Date();
switch(date.getDay()) {
case 6:
alert("This is weekend.");
break;
case 0:
alert("This is weekend.");
default:
alert("Looking for a weekend.");
break;
}
17
Q

JS “delete”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used to remove properties from an object.
  • Example
var fruits={f1: "apple", f2: "banana", f3: "orange"};
delete fruits.f1;
17
Q

JS “do”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used to define a do-while loop.
  • Example
var a=1;
do {
document.write("loop is running for " + a + "times</p>");
a++;
}
while(a <= 10);
18
Q

JS “double”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • In JavaScript, there is no double keyword
  • JavaScript has only one numeric data type: Number representing both integers & floating-point numbers
  • Internally, all JS numbers are stored as 64-bit floating-point values according to the IEEE 754 standard - equivalent to the double type in other languages.
  • Example
let x = 10;     // integer
let y = 3.14;   // floating-point number
let z = 1e10;   // scientific notation
19
Q

JS “else”

A
  • JS keyword
  • JS significant: avoid in variable/function names
  • Used in the if-else statement, the else indicates the block of statements to be executed if the expression evaluates false.
  • Example
var date = new Date();
var day = date.getDay(); // Sunday - Saturday : 0 - 6
if(day==5) {
alert("This is weekend!");
} else {
alert("This is non-weekend!");