-
If we need to convert a variable call str which value is "12" to number 12, which way cannot do this job?
- parseInt(str)
- Number(str)
- +str
- !!str
-
What is the result of the code:
let num = 255;
alert(num.toString(16));
- 255
- 'ff'
- NaN
- '255'
-
Which following expression is true?
- 0.1 + 0.2 === 0.3
- !!4
- true + 1 > 2
- '120' > '13'
-
What is the result of the code:
let num = 0.125 + 0.124;
alert(+num.toFixed(2));
- 0.25
- '0.249'
- '0.25'
- 0.249
-
What is the result of the code: parseInt('1.8em') ?
- NaN
- 1.8
- 1
- 2
-
To get the integer part of a float number: num (For example: get 12 from 12.8), which method can be used?
- Math.round(num)
- Math.abs(num)
- Math.floor(num)
- Math.ceil(num)
-
To get the random integer between 20 and 30, which method can be used?
- Math.round(Math.random() * 10) + 20
- Math.round(Math.random() * 30)
- Math.round(Math.random() * 10 + 20)
- Math.random() * 30
-
What is the result of the code:
let fruits = ["Apple", "Orange", "Plum"];
alert(fruits[3]);
- "Plum"
- "Orange"
- undefined
- throw an error
-
To get the last element of array, which method can be used?
- array[array.length - 1]
- array[array.length]
- array[-1]
- array[array.len() - 1]
-
To get the last element of array, which method can be used?
let arr = [1,3,3,2,1,1,5];
console.log(Array.from(new Set(arr)));
- [1,3,2,5]
- [1,3,3,2,1,1,5]
- [1,5]
- [1,3,3,2]
-
Which way is not the correct way to express a string?
- 'hello'
- "hello"
- `hello`
- /hello/
-
To get the last element of array, which method can be used?
str = `Hello`;
alert(1 + str.length + str[0]);
- '5H'
- '6H'
- '15H'
- '150'
-
Which following option is belong to the primitive types?
- Number
- Array
- Object
- Function
-
Which following option is belong to the composite types?
- Number
- String
- Boolean
- Function
-
Which result of the following code is correct?
function sum(a, b) {
return a + b;
}
alert(`1 + 2 = ${sum(1, 2)}.`);
- '1 + 2 = 3.'
- '1 + 2 = ${sum(1, 2)}.'
- '1 + 2 = (1, 2)).'
- '1 + 2 = function.'
-
Which is correct result of the code: 'Interface'.toUpperCase()?
- 'Interface'
- 'iNTERFACE'
- 'interface'
- 'INTERFACE'
-
To justify whether the string 'Hello' contains 'e', which method can be used?
- 'Hello'.indexOf('e') >= 0
- 'Hello'.contains('e')
- 'Hello'.has('e')
- 'Hello'.substring(1,2) === 'e'
-
To get the part of a string "stringify", which result is not "ring" ?
- str.substring(2, 6)
- str.substring(6, 2)
- str.slice(2, 6)
- str.slice(6, 2)
-
Which result of the following code is correct?
let fruits = ["Apple", "Orange", "Pear"];
fruits.pop();
alert(fruits);
- ["Apple", "Orange", "Pear"]
- ["Apple", "Orange"]
- ["Orange", "Pear"]
- []
-
Which result of the following code is correct?
let arr = [1, 2, 3, 4, 5];
let result = arr.reduce((sum, current) => sum + current, 0);
alert(result);
- 15
- 5
- 1
- 120
-
Which result of the following code is correct?
let user = {
name: "John",
age: 30
};
alert(Object.keys(user));
- [["name", "John"], ["age", 30]]
- ["name", "John", "age", 30]
- ["John", 30]
- ["name", "age"]
-
To get the day of month, we may use which method?
- getDate()
- getDay()
- getDayOfMonth()
- getDateOfMonth()
-
To convert an object to JSON string, we may use which method?
- JSON.stringify(obj)
- JSON.toString(obj)
- JSON.parse(obj)
- JSON.toJSONString(obj)