Which of the following statements about data values and objects in JS are true? Select one or more:
☐ true
is an object. ☐ A JS array is a JS object. ☐
false
is a data value.
☐ A JS function is a JS object. ☐ 1
is a data value. ☐
Infinity
is an object.
What is the value of the Boolean expression null || !0
? Select one:
O true O false
Which of the following denote primitive datatypes in JavaScript? Select one or more:
☐ double ☐ string ☐ float ☐ int ☐ boolean ☐ byte ☐ number
Which of the following JavaScript fragments correctly defines the
constructor-based class City
shown in the class diagram
(either using a constructor function definition or an ES6 class
definition)? Hint: notice that setName
is an instance-level
method while checkName
is a class-level ("static") method.
Select one or more:
☐
function City( n) { this.name = n; this.setName = function (n) {this.name = n;}; checkName = function (n) {...}; // returns true or false }
☐
class City { constructor (n) { setName(n); } setName(n) {if (City.checkName( n)) this.name = n;} static checkName(n) {...} // returns true or false }
☐
function City( n) { this.setName( n); function checkName( n) {...} // returns true or false } City.prototype.setName = function (n) {this.name = n;};
☐
function City( n) { this.setName( n); } City.prototype.setName = function (n) { if (City.checkName( n)) this.name = n; }; City.checkName = function (n) {...}; // returns true or false
Consider the following JavaScript code:
var a = 5; var b = "7"; var c = a + b;
What is the value of the variable c
? Select one:
O The string "57" O The number 12 O undefined
O The code will result in an error since you can't use the + operator between two operands of different types.