国外copy的JavaScript笔试题

声明: 一共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]

所有问题结束.....人肉复制确实有点累......

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,417评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,921评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,850评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,945评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,069评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,188评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,239评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,994评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,409评论 1 304
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,735评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,898评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,578评论 4 336
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,205评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,916评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,156评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,722评论 2 363
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,781评论 2 351

推荐阅读更多精彩内容