Answer these 1000+ JavaScript MCQs and assess your grip on the subject of JavaScript. Scroll below and get started!
A. subjective
B. evil
C. object based
D. objective
A. Math.PI.toString("D2")
B. Math.PI.toFixed(2)
C. Math.Round(Math.PI)
D. Math.PI.toPrecision(2)
A. Error: type mismatch
B. true
C. false
A. obj["age"] = 25 OR obj.age = 25
B. obj.age = 25 OR obj(@"age") = 25
C. obj(age) = 25 OR obj.age = 25
A. true
B. null
C. false
D. Throws Error, invalid comparison
A. a random number that can be any value
B. a random number between 0 and 100
C. a random number between 0 and 1
D. a random number between 0 and 1000
A. true
B. undefined
C. NaN
D. "!!foo"
A. var obj = new Object();
B. var obj = {};
C. function Foo() {} var obj = new Foo();
D. All of these work.
A. an underscore "_"
B. a colon ":"
C. a full-stop "."
D. a semicolon ";"
E. a comma ","
A. false
B. true
C. "B"
D. "A"
E. undefined
A. &
B. &&
C. ||
D. !
A. Math.ceil(x, y)
B. max(x, y)
C. top(x, y)
D. Math.max(x, y)
E. ceil(x, y)
A. A !== B
B. A !== B && B !== C && A !== C
C. A !== B & B !== C
D. A !== B || B !== C
A. The code inside a while loop will always be executed at least once, even if the condition is false.
B. The code inside a do...while loop will always be executed at least once, even if the condition is false.
C. There is no difference between them.
A. myArr.unshift();
B. myArr[0];
C. myArr.shift();
D. myArr[1];
E. myArr.pop();
A. while (...) { }
B. do { } while(...)
C. for (...) { }
D. repeat (...) { }
A. / This comment has more than one line /
B. // This comment has more than one line //
C. /* This comment has more than one line */
D. // This comment has mor than one line *//
A. To add a value to an array.
B. To delete a (global) variable.
C. To terminate an Object statement.
D. To divide (or "break") a mathematical value in half.
E. To terminate a switch statement, loop, or labeled block.
A. 100
B. $
C. 0
D. -1
E. 1
A. ++x is depreciated and replaced with x++;
B. x++ will return the value of x and then increment, where as ++x will increment the variable first then return its value.
C. They both do the same thing, just different syntax
A. Declare a member of a class
B. Change a constant
C. Create a new local variable
D. Retrieve a variable descriptor
A. number
B. All of these
C. string
D. boolean
A. for (var i=0; i < myArray.length; i++)
B. for (i = 0; i <= myArray.length;)
C. for (i < myArray.length; i++)
A. Return any number
B. Return a number raised to the power of a second number
C. Return a random value between 0 and 1
D. Return a variable value
A. 2
B. 3
C. 4
A. Math.round(7.25)
B. round(7.25)
C. Math.rnd(7.25)
D. rnd(7.25)
A. Yes
B. No
A. Just double quotes: "example"
B. Just single quotes: 'example'
C. Either double quotes or single quotes: "example" and 'example'
A. function myFunc(arg1, arg2):
B. func myFunc = (arg1 as string, arg2 as int) { }
C. function myFunc(arg1,arg2) { }
A. true
B. false
A. x.__type;
B. typeof(x);
C. Object.type(x);
D. gettype(x);
A. Cancels the current event.
B. Aborts the current loop or switch statement.
C. Aborts the current function.
D. Simulates a JavaScript crash.
A. An error is thrown because of illegal out of scope access.
B. "foo + bar"
C. NaN
D. "foobar"
E. "undefinedundefined"
A. var names = array("Tim", "Kim", "Jim");
B. var names = {1: "Tim", 2:"Kim", 3:"Jim"};
C. var names = {0: "Tim", 1: "Kim", 2: "Jim"};
D. var names = ["Tim","Kim","Jim"];
A. // comment
B. \\ comment
C.
D. -- comment
E. # comment
A. new fName = { }
B. func fName = function () {}
C. None of these
D. function fName() { }
E. function fName: { }
A. ||
B. &&
C. %
D. !
A. string myVar = "This is a string";
B. var myVar = "This is a string";
C. var string myVar = "This is a string";
A. throw
B. program
C. void
D. return
A. new john = Person('John', 'Doe', 50, 'blue');
B. var Person john = new Person('John', 'Doe', 50, 'blue');
C. var john = new Person('John', 'Doe', 50, 'blue');
D. Person john = new Person('John', 'Doe', 50, 'blue');
A. if (x = 1) { }
B. if (x ==== 1) { }
C. if (x === 1) { }
D. if (x == 1) { }
A. 5
B. 2
C. 24
D. Other/Error
A. +
B. &
C. All of these
D. .
A. Strongly typed, variables are declared with a type, and you can not assign another type to the variable.
B. Loosely typed, values of any type can be assigned to any variable.
A. none of these
B. the dot notation in JavaScript.
C. the redirect notation in JavaScript.
A. lastIndex
B. source
C. All of these
D. ignoreCase
A. Only returns true if the argument is not a number
B. Converts a non-numeric value to a number.
C. Throws an error if a conditional statement is false.
A. used inside of an `if` statement. To specify the code that should execute if the `if` condition is no longer true.
B. used together with the `if` statement to specify the code that should execute when the `if` condition is false.
C. Does not exist, in JavaScript `or` and `then` are used to specify code to execute for the "false" case of the `if` statement.
A. Represent the name of different variables
B. Represent the name of the same constant
C. Represent the name of the same variable
D. Represent the name of different constants
A. Manipulating Web Page Behaviors
B. Styling web pages
C. A website cannot be created without JavaScript
D. None of the above.
E. Content definition within web pages
A. true
B. false
C. 3
D. 2
E. 1
A. The == operator converts both operands to the same type, whereas === returns false for different types.
B. The == is used in comparison, and === is used in value assignment.
C. The === is deprecated, and now they are exactly the same.
A. ===
B. =
C. None of these
D. ==
A. []
B. [2,3,4,5]
C. [1,2,3,4]
D. [1,2,3,4,5]
A. An action to take at the beginning of the loop cycle
B. An action to take at the end of the current loop cycle
C. A condition to check at the beginning of a loop cycle
A. arguments_if_any ( function_expression )
B. function_expression ( arguments_if_any )
C. ( arguments_if_any ) -> function_expression
D. function_expression { arguments_if_any }
E. function_expression -> ( arguments_if_any )
A. onclick
B. onblur
C. onchange
D. onmove
A. "foobar"
B. foo( )
C. TypeError: undefined is not a function
D. undefined
E. ReferenceError: foo is not defined
A. An array with all of the distinct keys from the obj a
B. An obj with autowired getters and setters for it's key/values
C. A serialized copy of the obj a
A. 15
B. "123"
C. The statement generates an error.
D. 6
A. ASCII ordering
B. Ascending alphabetical
C. Descending alphabetical
D. All of these
A. false
B. true
A. the first or last value in the array
B. Moderate
C. An error to the browser
D. undefined
E. A default value, like 0
A. myConstructor x = create myConstructor();
B. myConstructor x = new myConstructor();
C. var x = create myConstructor();
D. var x = new myConstructor();
A. RangeError
B. Error
C. EvalError
D. All of these
A. Represents a variable
B. Does not exist in JavaScript
C. Is obsolete
D. Is a very important property
A. x = a ? b : c;
B. x = a : b ? c;
C. x = a ? b , c;
A. All of these
B. +=
C. %=
D. =
A. function doSomething() {}
B. all of these
C. function:doSomething() {}
D. function=doSomething() {}
A. var x = array("blank", "blank", "blank”);
B. var x = {"blank","blank","blank"};
C. var x = new Array(1:"blank",2:"blank",3:"blank")
D. var x = ["blank","blank","blank"];
A. HTML
B. ActionScript
C. ECMAScript
D. VBScript
A. 0
B. 4
C. 3
D. Throws a MathError exception.
A. var anon = new Function () { };
B. var anon = function() { };
C. var anon = func() { };
D. var anon = func({});
A. Provides access to Windows registry express values
B. Regulates the expression of variables
C. Match text against regular expressions
D. Switches numerical notation to exponential
E. Registers experienced functions with the DOM
A. throw
B. None, these are all valid statements.
C. continue
D. break
A. None of these
B. Number.prototype
C. String.prototype
D. Array.prototype
A. arr[arr.length()] = value;
B. arr[value] = length;
C. arr[arr.length] = value;
D. arr.length = value;
A. None of these does that and/or such method doesn't exist in javascript!
B. "x".add("foo")
C. "x".match("foo")
D. "x".combine("foo")
E. "x".concat("foo")
A. typeof
B. Type
C. typename
D. getType
E. TypeOf
A. "4"
B. "22"
C. 22
D. 4
A. double
B. string
C. number
D. object
E. boolean
A. 1
B. -1
C. i
D. 1.0
E. NaN
A. 'One' + 'Two' + 'Three'
B. 'One'.concat('Two', 'Three')
C. Both of these
A. var myArray = ();
B. var myArray = [];
C. var myArray = array();
D. var myArray = new Array[];
E. var myArray = {};
A. integer
B. tinyint
C. negative
D. positive
E. boolean
A. '234'
B. 9
C. '27'
A. var x = y === true : "true" ? "false";
B. var x = ( y === true ) : "true" ? "false";
C. var x = y === true ? "true" : "false";
D. var x = ( y === true ) { "true" : "false" };
A. null
B. undefined
C. ['Hello']
D. "Hello"
E. NULL
A. SyntaxError
B. false
C. undefined
D. true
var foos = ['a', 'b', 'c' , 'd', 'e']; var bars = ['x', 'y', 'z']; for (var i = 0; i < foos.length; i++) { var foo = foos[i]; for (var i = 0; i < bars.length; i++) { var bar = bars[i]; /* some code using `bar` */ } }
A. The inner loop resets the outer for-loop, leaving it a fixed position each time, causing an infinite loop (hint: no block scope).
B. The outer-loop finishes after the first iteration due to a "bug" that unfortunately is part of the ECMAScript specification.
C. Uncaught SyntaxError.
D. There is no bug. The loop will run correctly.
A. undefined
B. null
C. NaN
D. closure
E. false
A. if (x === 5) { ... }
B. if (x == 5) { ... }
C. if x = 5 then ...
D. if x = 5 ...
A. null
B. 10
C. "bar"
D. 7
E. undefined
A. Code to execute once, after the loop has ended
B. A condition to check at the end of each loop cycle
C. Code to execute once, before the loop starts
D. A condition to check at the beginning of each loop cycle
A. Setting attributes
B. Block declarations and object literals
C. Invoking a function
D. Parsing JSON
E. Defining a class
A. {};
B. [];
C. nil;
D. object;
E. ();
A. operators
B. loops
C. objects
D. in the global scope
A. JSON.parse
B. JSON.fromString
C. JSON.stringify
A. true
B. false
A. Alters stringVar, changes all letters to uppercase
B. Return the number of characters in the stringVar variable
C. Evaluate any string expression in stringVar
D. Return a copy of stringVar with all letters in uppercase