声明: 一共40道题,从Upwork的test 里边copy 过来的, 单纯学习目的,只是为了准备Oracle的笔试题. 毕竟都是为了考试能过,能背一些或者说只要能分数高点能过笔试就谢天谢地了. 为了方便做题: 题目在前面 答案在后边. 有些问题感觉确实奇葩,有些问题简单,有些确实考的基础没咋用到,希望对大家有帮助,对我自己也是一个提高.
我要答案
全部人肉搬运,也欢迎大家共同讨论.
1:what is the value of ''n1" and "n2" after executing the following code?
var str = "Finding foo in Foo and Bar";
var n1 = str.search("Foo");
var n2 = str.search(/Foo/i)
a: n1 = 15 ,n2 =15,
b: n1 = 15, n2 = 8,
c: n1 = 8,n2 = 8
2: what command skips the rest of a case statement?
a : return
b: exit
c: continue;
d: break;
3.what will be returned if we call f(1);?
const b = [1,2,3];
const f = (a,...b) => a + b;
a : 7;
b : 1;
c : 6;
d : some error;
4: Cookies are a plain text data record with the following variable-length fields?
Note: There may be more than one right answer;
a: Secure;
b: Domain;
c: Package;
d: Media;
e:Navigator;
5:Which JavaScript class represents regular expression ?
a: RegExpObj;
b: RegExp;
c: RegExpClass;
d: StringExp;
6: How do you find the number with the highest value of variable a and b ?
a: top(a,b);
b: Math.max(a,b);
c: Math.ceil(a,b);
d: Math.highest(a,b);
7: what will be the output of following code snippet?
var result = (function(a){
return a * a;
}(5.5));
alert(result);
a: 5;
b: 25;
c: 10;
d: 30.25;
8: which of the following determines the type of a given object ?
a: variable;
b: typeof ;
c: string;
d: object;
9: What is the value of b?
let a = [1,2,3,4,5];
let b = [1,2 ,...a]
a: [1,2,3,4,5];
b: [1,2,1,2,3,4,5]
c: some error;
d: [1,2];
e: [3,4,5]
10 : What is the correct way to create a JavaScript array ?
a: var cars = ["Saab","Volvo","BMW"];
b: var cars = "Saab","Volvo","BMW";
c: var cars = 1 =("Saab"),2=("Volvo"),3=("BMW");
d: var cars = (1:"Saab",2:"Volvo",3:"BMW");
11:What will be logged to console?
let arr = [1,2,3];
for(i = 0 ;i < arr.length;arr[i++] = 0) ;
console.log(arr);
a: Nothing
b: SyntaxError
c: ReferenceError
d: TypeError
e: [1,2,3]
[1,2,3]
[1,2,3]
f:[0,0,0]
12:What is the output of below code ?
x = 50/"Apple";
alert(x);
a : undefined;
b: NaN
c: Infinity;
d: 50;
13:How do you locate the first X in a string variable named txt ?
a: txt.find("X");
b: txt.locate("X");
c: txt.indexOf("X");
d: txt.countTo("X");
14:Which is the correct way to create an Object ?
a: var fooObj = new Object();
b: var fooObj = {};
c: Both of the above;
d: None of these;
15: What is the event that fires when the formal element textarea loses the focus?
a: Onclick ;
b: OndbClick;
c: Onfocus;
d: Onblur;
16: What will be logged in the console?
let a = {
['foo_' + (() => 1)()] : 2
};
console.log(a);
a: TypeError;
b:SyntaxError;
c: {foo_1:2};
d: ReferenceError;
17:Which of the following is used in JavaScript to inner special characters?
a: & ;
b: +;
c: -;
d: %;
e: None of the above;
18:Select all the statements that will return true.Object is defined: let a = {a: 1} ;
Note:There may be more than one right answer;
a: delete a.a;
b: delete a.b;
c: 1 != Boolean('-1');
d: Boolean(1) == Boolean('-1');
e: Boolean(null) != Boolean('0');
f: All of them will return true;
19: Which example is correct of Local Scope Varialbe?
a :
var b = 3 ;
function myFunc(){
return b * b;
}
b :
function myFunc(){
var b = 3 ;
return b * b;
}
c :
var a = 2;
function myFunc(){
return a;
}
d: all of the above;
20: which of the following is not a mouse event?
a : onmousescroller;
b: onclick;
c: onmouseover;
d: onmousemove;
21:What is the correct syntax for referring to an external script called "test.js" ?
a: <script name="test.js">
b: <script href = "test.js">
c: <script src = "test.js">
d: None of these
22: Which of the following is an incorrect way of instantiating a date?
a: new Date(dateString);
b: new Date();
c: new Date(second);
d: new Date(year,month,day,hours,minutes,seconds,milliseconds);
23: What are valid states of the created Promise?
Note: There may be more than one right answer.
a: pending;
b: fulfilled;
c: initializing;
d: rejected;
24:How can you create a function with the JavaScript Function constructor?
a : var func = Function("x", "y" ,"return x + y")
b : var func = new Function("x", "y" ,"return x + y")
c : var func = Function(x,y){return x + y;}
d : None of the above;
25: Select the statement that will return truthy value, Array let a = [1,2,3,4]
is defined.
Note:There may be more than one right answer;
a: 4 in a;
b: a.indexOf(-1) ===3;
c: a.length;
d: a;
26: JavaScript JSON data manipulation- How can you access first,last name properties in data object using the following snippet?
var data = {"users" : [
{ "firstName" : "Ali",
"lastName" : "Rehman",
"birthday" : {
"month" :"January",
"day" : 20,
"year" : 1983
}
}
]}
a: document.write(data.users.firstName);
b: document.getElementById("placeholder").innerHTML = data.users.firstName;
c: document.getElementById("placeholder").innerHTML = data.users[0].firstName + " " + data.users[0].lastName + "-" + data.users[0].birthday.month.
d: document.getElementById("placeholder").innerHTML = data.users[0].firstName + " " + data.users[0]
27: Select options which create object type variables:
Note : There may be more than one right answer;
a: let a = '';
b: let a = {}
c:let a = []
d:let a = new String("a")
e: let a= null
28 :what's true about numbers in JavaScript? (choose all that apply)
Note: There may be more than one right answer;
a: There is no such type as integer;
b: There are positive and negative infinity numbers;
c: (Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER +2)
will return false;
d: Number.parseInt() can be used to return integer value of a number;
e: All of these;
29: Evaluate the following expression: ~-(2 + "2")
a: undefined;
b: SyntaxError;
c: 21;
d: -22;
30 : what will the following code return : Boolean (6> 5)
a: NaN;
b: false;
c: true;
d: 1;
31: what will be the value of a?
let a = -1 ?'foo' ?null: -1 :1;
a: foo;
b: null;
c: -1;
d: 1;
32: which function will return 10 when called like this: f(10);
Note : There may be more than one right answer;
a: const f = (...f) => f;
b: const f = (...f) => f.reduce(f => f);
c: function f(){ return arguments; }
d: const f = f =>f;
33: What will be the output of this snippet?
var foo = 10;
bar =3;
(function(){
var foo = 2;
bar = 1;
}())
bar = bar +foo;
alert(bar);
a: 11;
b: 3;
c: 30;
d: 12;
34: How do you remove property a from this object?
let a = { a: 1,b:2};
a: a.a = null
b: a.a = false
c: a.a = 'undefined'
d: delete a.a
e: remove a.a
35.What will be logged in console.?
const data = [{a: true,b: false},{a:false,b:true}];
let result = false;
let sample ;
while(sample = data.pop()){
result = sample.a;
}
console.log(result);
a: ReferenceError;
b: TypeError;
c: true;
d: false;
36:How can you get DOM element style assuming there is an element with id = "id"?
Note: There may be more than one right answer;
a: document.getElementById("id").setAttribute("style","color:red;font-size:10px");
b: document.getElementById("id").style.cssText = "color:red;font-size:10px";
c: document.getElementById("id").style.color = "red";
d: document.getElementById("id").style.text.color = "red";
37: Select the statement that will return false. First line in file is : var a = true;b = false;
a: This code will throw an error;
b: delete a ===b;
c: delete a;
d: delete b;
e: delete c;
38: Arrow function expression has a shorter syntax than a funtion expression and dose not bind its own as follow?
a: arguments,prototype;
b: arguments,class;
c: arguments,super;
d: prototype, object
39: For the following html element,which is the correct method to change the font size to 25px,using javaScript?
<p id="foo">Lorem Ipsum</p>
a: document.getElementById("foo").setFontSize = "25px";
b: document.getElementById("foo").style.fontSize = "25px";
c: document.getElementById("foo").fontSize = "25px";
d: document.getElementById("foo").style("font-size = 25px");
40: What will be logged to the console? console.log([0,0,0].fill(1,1));
a: RangeError
b: SyntaxError;
c: EvalError;
d: [0,1,1];
e:[1,1,1];
f:[1,0,0];
g:[0,1,0]
所有问题结束.....人肉复制确实有点累......