Organization final javascript

Ace your homework & exams now with Quizwiz!

What would the result be of the following function: let myFunc = (x,y) => { x++; y++; return x + y; }; myFunc(3,4); a. 9 b. 7 c. 12 d. 8 e. undefined

a. 9

Which statement below best describe block scope? a. Block scoped variables are only scoped within the block they are declared in. b. Block scoped variables are global scoped. c. Block scoped variables defined in a function are visible to the entire function. d. Block scoped variables can be seen outside an if statement. e. All of the above

a. Block scoped variables are only scoped within the block they are declared in.

What would be the output of the following code? class Cat { constructor(name) { this.name = name; } speak() { console.log(this.name + ' makes a noise.'); } } class Lion extends Cat { speak() { super.speak(); console.log(this.name + ' roars.'); } } var l = new Lion('Fuzzy'); l.speak(); a. Fuzzy makes a noise, Fuzzy roars b. Fuzzy roars, Fuzzy makes a noise c. undefined makes a noise, undefined roars d. Undefined, Undefined.

a. Fuzzy makes a noise, Fuzzy roars

Which of the statements below is NOT correct about expressions in JavaScript? a. JavaScript does not use short circuits in expressions. b. The operators include in JavaScript expressions are ternary, arithmetic, comparison, string, and logical c. JavaScript allows an expression that has the operator before or after an operand. d. JavaScript void evaluates an expression without returning a value.

a. JavaScript does not use short circuits in expressions.

Variable Hoisting refers to what in JavaScript? a. The ability to refer to something before it is declared without getting a reference error. b. The ability to initialize a variable before using the variable. c. The ability to change the scope of a variable from global to local. d. The ability to make two variables be encapsulated together.

a. The ability to refer to something before it is declared without getting a reference error.

What would the result be of the following function: let myFunc = x => console.log(x+5); myFunc(5); a. 1 b. 10 c. 20 d. 6 e. undefined

b. 10

Which best describes global scope in JavaScript a. A variable declared with var, let, or const inside a function becomes a global variable. b. Any variable defined outside of a function is a global variable. c. All variables in JavaScript have global scope. d. All variables in JavaScript have local scope.

b. Any variable defined outside of a function is a global variable.

Which one of the following statements about JavaScript is NOT correct? a. JavaScript is a case-sensitive language b. JavaScript is white space sensitive c. Var are used to declare variables d. In JavaScript variables without a value are undefined

b. JavaScript is white space sensitive

If given the following code what would the output be when the program executes the following line: console.log(myvar); var myvar = 'my value'; (function() { var myvar; console.log(myvar); myvar = 'local value'; })(); a. my value b. undefined c. local value d. reference error

b. undefined

What would the result be if you ran the following code: function makeAdder(x) { return function(y) { return x + y; }; } var add8 = makeAdder(8); var add12 = makeAdder(12); console.log(add8(4)); console.log(add12(5)); a. 10, 12 b. 7, 12 c. 12,17 d. undefined, 17 e. 17, 12

c. 12,17

Which of the following statements about JavaScript functions is NOT correct? a. JavaScript functions can be hoisted. b. JavaScript functions are first class value. c. JavaScript function expressions can be hoisted. d. JavaScript functions allow pass-by-value

c. JavaScript function expressions can be hoisted.

_____ is a set of statements to perform a task or calculate a value. a. Variable b. Hoisting c. Procedure d. Operator

c. Procedure

Fill in the blanks: ______ via functions, allow inner functions to have access to outer functions variables allowing ______ a. scoping, closures b. closures, scoping c. lexical scoping, closures d. recursion, lexical scoping

c. lexical scoping, closures

What would the output of the following code be: function sum() { return this.a + this.b + this.c; } var o = {a: 3,b: 4,c: 5, get average() { return (this.a + this.b + this.c) / 3; } }; Object.defineProperty(o, 'sum', {get: sum, enumerable: true, configurable: true}); console.log(o.average, o.sum); a. 2,6 b. 3,6 c. 5,12 d. 4,12

d. 4,12

Which statements about JavaScript objects is correct? a. Objects have key value pairs which can be any type. b. The keys used in objects can be Strings or Symbols but not numbers. c. Literals imply they are literally declared. d. All of the above.

d. All of the above.

Which of the following is NOT true about recursion in JavaScript? a. Recursion can be done by calling the function name. b. You can use arguments.callee for recursion. c. You can use an in-scope variable referring to function. d. JavaScript does not allow recursion.

d. JavaScript does not allow recursion.

Which of the following are primitives in JavaScript? a. String b. Number c. Boolean d. Undefined e. All of the Above

e. All of the Above

Which best describes what type of programming language JavaScript is? a. Interpreted b. Imperative c. Functional d. Object Oriented e. All of the above

e. All of the above

Which statement about ECMA is correct? a. Just a noun. Not an acronym. b. Used to be European Computer Manufacturers Association in the before times of 1994. c. Member-based organization which produces technical standards d. Freely usable products e. All of the above

e. All of the above

Which of the following is not a trend in JavaScript? a. Node.JS b. Type Safety c. Functional Programming d. Web Assembly e. None of the Above

e. None of the Above


Related study sets

Solving Quadratic Equations by Factoring, Set 7

View Set

Unit 8 Practice Quizzes - Imperfect Competition

View Set

History Alive- Chapter 20 - Heian-kyo: The Heart of Japan's Golden Age (20.1-20.3/Part 1)

View Set

(29) 18.3 Formed Elements in the Blood & 18.3a Hemopoiesis

View Set