一份来自于全球的前端面试题清单,看看老外喜欢考哪些题(部分有答案)(二)

简介:  方括号中的蓝色标题是题目的出处,有些题目在原址内包含答案。搜集的大部分外国前端面试题没有做翻译,单词并不难,大家应该看得懂。题目旁边的方括号内, 简单记录了与此题相关的知识点。总共大概一千多道,包含国内的题目,如有错误,欢迎指正。有些原链可能已无法打开,有些可能需要代理才能查看。

178、What is undefined x 1 in JavaScript?【chrome和firefox表现不同】

var trees = ["redwood", "bay", "cedar", "oak", "maple"];
delete trees[3];
console.log(trees);


179、What will be the output of the code below?

var trees = ["xyz", "xxxx", "test", "ryan", "apple"];
delete trees[3];
console.log(trees.length);

180、What will be the output of the code below?【+】

var bar = true;
console.log(bar + 0);
console.log(bar + "xyz");
console.log(bar + true);
console.log(bar + false);


181、What will be the output of the code below?【连续=】

var z = 1,
  y = (z = typeof y);
console.log(y);

182、What will be the output of the code below?

// NFE (Named Function Expression
var foo = function bar() {
  return 12;
};
typeof bar();


183、What is the difference between the function declarations below?

var foo = function() {
  // Some code
};
function bar() {
  // Some code
}


184、What is function hoisting in JavaScript?什么是JavaScript中的函数提升?

185、What will be the output of code below?【提升】


var salary = "1000$";
(function() {
  console.log("Original salary was " + salary);
  var salary = "5000$";
  console.log("My New Salary " + salary);
})();

186、What is the instanceof operator in JavaScript? What would be the output of the code below?【instanceof】


function foo() {
  return foo;
}
new foo() instanceof foo;

187、If we have a JavaScript associative array.How can we calculate the length of the above associative array's counterArray?


var counterArray = {
  A: 3,
  B: 4
};
counterArray["C"] = 1;


【25 Essential JavaScript Interview Questions*】

188、What is a potential pitfall with using typeof bar === "object" to determine if bar is an object? How can this pitfall be avoided?

189、What will the code below output to the console and why?【连续=】


(function() {
  var a = (b = 3);
})();
console.log("a defined? " + (typeof a !== "undefined"));
console.log("b defined? " + (typeof b !== "undefined"));


190、What will the code below output to the console and why?【this】



var myObject = {
  foo: "bar",
  func: function() {
    var self = this;
    console.log("outer func:  this.foo = " + this.foo);
    console.log("outer func:  self.foo = " + self.foo);
    (function() {
      console.log("inner func:  this.foo = " + this.foo);
      console.log("inner func:  self.foo = " + self.foo);
    })();
  }
};
myObject.func();

191、What is the significance of, and reason for, wrapping the entire content of a JavaScript source file in a function block?将192、JavaScript源文件的全部内容包装在功能块中的意义和原因是什么?

193、What is the significance, and what are the benefits, of including 'use strict' at the beginning of a JavaScript source file?

Consider the two functions below. Will they both return the same thing? Why or why not?【分号】

function foo1(){
  return {
     bar: "hello"
   };
}
function foo2(){
   return
   {
     bar: "hello"
   };
}


194、What is NaN? What is its type? How can you reliably test if a value is equal to NaN?

195、What will the code below output? Explain your answer.【Number】


console.log(0.1 + 0.2);
console.log(0.1 + 0.2 == 0.3);

196、Discuss possible ways to write a function isInteger(x) that determines if x is an integer.

197、In what order will the numbers 1-4 be logged to the console when the code below is executed? Why?【定时器】


(function() {
  console.log(1);
  setTimeout(function() {
    console.log(2);
  }, 1000);
  setTimeout(function() {
    console.log(3);
  }, 0);
  console.log(4);
})();

198、Write a simple function (less than 80 characters) that returns a boolean indicating whether or not a string is a palindrome.【字符串是否是回文】

199、Write a sum method which will work properly when invoked using either syntax below.


console.log(sum(2, 3)); // Outputs 5
console.log(sum(2)(3)); // Outputs 5

200、Consider the following code snippet:


for (var i = 0; i < 5; i++) {
  var btn = document.createElement("button");
  btn.appendChild(document.createTextNode("Button " + i));
  btn.addEventListener("click", function() {
    console.log(i);
  });
  document.body.appendChild(btn);
}


   (a) What gets logged to the console when the user clicks on “Button 4” and why?

   (b) Provide one or more alternate implementations that will work as expected.

201、What will the code below output to the console and why?【数组】


var arr1 = "john".split("");
var arr2 = arr1.reverse();
var arr3 = "jones".split("");
arr2.push(arr3);
console.log("array 1: length=" + arr1.length + " last=" + arr1.slice(-1));
console.log("array 2: length=" + arr2.length + " last=" + arr2.slice(-1));


202、What will the code below output to the console and why ?【隐式类型转换】


console.log(1 + "2" + "2");
console.log(1 + +"2" + "2");
console.log(1 + -"1" + "2");
console.log(+"1" + "1" + "2");
console.log("A" - "B" + "2");
console.log("A" - "B" + 2);


203、The following recursive code will cause a stack overflow if the array list is too large. How can you fix this and still retain the recursive pattern?【递归,setTimeout】


var list = readHugeList();
var nextListItem = function() {
  var item = list.pop();
  if (item) {
    // process the list item...
    nextListItem();
  }
};


204、Wha is a “closure” in JavaScript? Provide an example.

205、What will be the output of the following code:【闭包】

for (var i = 0; i < 5; i++) {
  setTimeout(function() {
    console.log(i);
  }, i * 1000);
}


   Explain your answer. How could the use of closures help here?

206、What would the following lines of code output to the console?【假值、与、或】


console.log("0 || 1 = " + (0 || 1));
console.log("1 || 2 = " + (1 || 2));
console.log("0 && 1 = " + (0 && 1));
console.log("1 && 2 = " + (1 && 2));

207、What will be the output when the following code is executed? Explain.【==,===】


console.log(false == "0");
console.log(false === "0");

208、What is the output out of the following code? Explain your answer.【隐式类型】


var a = {},
  b = { key: "b" },
  c = { key: "c" };
a[b] = 123;
a[c] = 456;
console.log(a[b]);


209、What will the following code output to the console:【递归】


console.log(
  (function f(n) {
    return n > 1 ? n * f(n - 1) : n;
  })(10)
);

210、Consider the code snippet below. What will the console output be and why?【作用域】


(function(x) {
  return (function(y) {
    console.log(x);
  })(2);
})(1);

211、What will the following code output to the console and why:


var hero = {
  _name: "John Doe",
  getSecretIdentity: function() {
    return this._name;
  }
};
var stoleSecretIdentity = hero.getSecretIdentity;
console.log(stoleSecretIdentity());
console.log(hero.getSecretIdentity());


212、Create a function that, given a DOM Element on the page, will visit the element itself and all of its descendents (not just its immediate children). For each element visited, the function should pass that element to a provided callback function.【访问后代】

   The arguments to the function should be:

   a DOM element

   a callback function (that takes a DOM element as its argument)

【5 More JavaScript Interview Exercises】

213、What will be printed on the console if a user clicks the first and the fourth button in the list? Why?【Closures】


var nodes = document.getElementsByTagName("button");
for (var i = 0; i < nodes.length; i++) {
  nodes[i].addEventListener("click", function() {
    console.log("You clicked element #" + i);
  });
}

214、What’s the output?【Data Types】

console.log(typeof null);
console.log(typeof {});
console.log(typeof []);
console.log(typeof undefined);

215、What is the result of the following code? Explain your answer.【Event Loop】

function printing() {
  console.log(1);
  setTimeout(function() {
    console.log(2);
  }, 1000);
  setTimeout(function() {
    console.log(3);
  }, 0);
  console.log(4);
}
printing();


216、Write an isPrime() function that returns true if a number is prime and false otherwise.【Algorithms】

【5 Typical JavaScript Interview Exercises】

217、What will be printed on the console?【Scope】


(function() {
  var a = (b = 5);
})();
console.log(b);


218、Define a repeatify function on the String object. The function accepts an integer that specifies how many times the string has to be repeated. The function returns the string repeated the number of times specified. For example:【Create “native” methods】

  console.log('hello'.repeatify(3));

219、What’s the result of executing this code and why.【Hoisting】


function test() {
  console.log(a);
  console.log(foo());
  var a = 1;
  function foo() {
    return 2;
  }
}
test();


220、How this works in JavaScript【this】


var fullname = "John Doe";
var obj = {
  fullname: "Colin Ihrig",
  prop: {
    fullname: "Aurelio De Rosa",
    getFullname: function() {
      return this.fullname;
    }
  }
};
console.log(obj.prop.getFullname());
var test = obj.prop.getFullname;
console.log(test());


221、call() and apply()

【JavaScript interview questions and answers】

222、What are global variables? How are they declared? What are the problems with using globals?【全局变量】

223、How do you organize your JavaScript code?

224、What are JavaScript types?

225、What is the difference between undefined and null?

226、What is JavaScript's this keyword?

227、What is event bubbling?

228、Do you have a JavaScript framework preference? What are your thoughts on using frameworks?【你对使用框架有什么想法?】

229、How are errors gracefully handled in JavaScript?

230、Can you explain how inheritance works in JavaScript?

231、How do JavaScript timers work? What is a drawback of JavaScript timers?定时器缺点

【JavaScript 123 interview Question】

232、what is function hoisting in JavaScript?【hoisting】

var foo = function foo() {
  return 12;
};


233、What will be the output of the following code?


var salary = "1000$";
(function() {
  console.log("Original salary was " + salary);
  var salary = "5000$";
  console.log("My New Salary " + salary);
})();

234、Difference between Function, Method and Constructor calls in JavaScript.

235、What would be the output of the following code?【连续=】



function User(name) {
  this.name = name || "JsGeeks";
}
var person = (new User("xyz")["location"] = "USA");
console.log(person);


236、What is the difference between a method and a function in javascript?

237、What is JavaScript Self-Invoking anonymous function or Self-Executing anonymous function.

238、Describe Singleton Pattern In JavaScript?【设计模式】

239、What are the way by which we can create object in JavaScript ?

240、Write a function called deepClone which takes an object and creates a object copy of it.【clone】

241、Best way to detect undefined object property in JavaScript.

242、How to check whether a key exist in a JavaScript object or not.

243、write a function called Clone which takes an object and creates a object copy of it but not copy deep property of object.【clone】

244、What is best way to detect an arrays object on JavaScript ?

245、Best way to detect reference values of any type in JavaScript ?【typeof】

   In Javascript Object are called as reference type, Any value other then primitive is definitely a reference type. There are several built-in reference type such as Object, Array, Function, Date, null and Error.

246、Describe Object-Based inheritance in JavaScript.

   Object-based inheritance also called prototypal inheritance in which we one object inherit from another object without invoking a constructor function.

   The ECMAScript 5 Object.create() method is the easiest way for one object to inherit from another.

247、Describe Type-Based inheritance in JavaScript.

   Type-based inheritance works with constructor function instead of object, It means we need to call constructor function of the object from which you want to inherit.

248、How we can prevent modification of object in JavaScript ?.

   ECMAScript 5 introduce several methods to prevent modification of object which lock down object to ensure that no one, accidentally or otherwise, change functionality of Object.

【Javascript Interview Questions】

249、What is JavaScript?

250、Name some of the JavaScript features.

251、What are the advantages of using JavaScript?

252、What are disadvantages of using JavaScript?

253、Is JavaScript a case-sensitive language?

254、How can you create an Object in JavaScript?

255、How can you read properties of an Object in JavaScript?

256、How can you create an Array in JavaScript?

257、What is a named function in JavaScript? How to define a named function?命名函数

258、How many types of functions JavaScript supports?

259、How to define a anonymous function?

260、Can you assign a anonymous function to a variable?

261、Can you pass a anonymous function as an argument to another function?

262、What is arguments object in JavaScript?

263、How can you get the type of arguments passed to a function?

264、How can you get the total number of arguments passed to a function?

265、How can you get the reference of a caller function inside a function?

266、What is the purpose of 'this' operator in JavaScript?

267、What are the valid scopes of a variable in JavaScript?【变量】

268、Which type of variable among global and local, takes precedence over other if names are same?【变量优先级】

269、What is callback?

270、What is closure?

271、Give an example of closure?

272、Which built-in method returns the character at the specified index?【charAt】

273、Which built-in method combines the text of two strings and returns a new string?【concat】

274、Which built-in method calls a function for each element in the array?【forEach】

275、Which built-in method returns the index within the calling String object of the first occurrence of the specified value?【indexOf】

276、Which built-in method returns the length of the string?【length】

277、Which built-in method removes the last element from an array and returns that element?【pop】

278、Which built-in method adds one or more elements to the end of an array and returns the new length of the array?【push】

279、Which built-in method reverses the order of the elements of an array?【reverse】

280、Which built-in method sorts the elements of an array?【sort】

281、Which built-in method returns the characters in a string beginning at the specified location?【substr】

282、Which built-in method returns the calling string value converted to lower case?【toLowerCase】

283、Which built-in method returns the calling string value converted to upper case?【toUpperCase】

284、Which built-in method returns the string representation of the number's value?【toString】

285、What are the variable naming conventions in JavaScript?【命名规范】

286、How typeof operator works?【typeof】

287、What typeof returns for a null value?

288、Can you access Cookie using javascript?【Cookie】

289、How to create a Cookie using JavaScript?

290、How to read a Cookie using JavaScript?

291、How to delete a Cookie using JavaScript?

292、How to redirect a url using JavaScript?

293、How to print a web page using javascript?

294、What is Date object in JavaScript?

295、What is Number object in JavaScript?

296、How to handle exceptions in JavaScript?

297、What is purpose of onError event handler in JavaScript?【error】

【Top 85 JavaScript Interview Questions & Answers】

298、Enumerate the differences between Java and JavaScript?

299、What is the use of isNaN function?【NaN】

300、What is negative infinity?

301、What are undeclared and undefined variables?

302、Explain how can you submit a form using JavaScript?

303、How can the style/class of an element be changed?

304、What are all the looping structures in JavaScript?【variable typing】

305、Explain how to detect the operating system on the client machine?【navigator.appVersion】

306、What is the use of Void(0)?

307、What are escape characters?【escape】

308、Mention what is the disadvantage of using innerHTML in JavaScript?

309、What are the two basic groups of dataypes in JavaScript?【Primitive与Reference types】

310、How generic objects can be created?

311、Which keywords are used to handle exceptions?

312、What is the way to get the status of a CheckBox?

313、How can a value be appended to an array?

314、Explain the for-in loop?

315、Describe the properties of an anonymous function in JavaScript?

316、What are the various functional components in JavaScript?

317、Write about the errors shown in JavaScript?

318、What are the decodeURI() and encodeURI()?【decodeURI和encodeURI】

【JavaScript Interview Questions】  

  Closures, scope, hoisting, the JS object model, and more.

【一些开放性题目】

319、Javascript垃圾回收方法

320、哪些操作会造成内存泄漏?

321、WEB应用从服务器主动推送Data到客户端有那些方式?

322、说说严格模式的限制

【JavaScript Patterns Collection】

  JavaScript知识点合集、包括语法、设计模式、jQuery等

【JOB INTERVIEW QUESTIONNAIRE】

323、Describe a strategy for memoization (avoiding calculation repetition) in JavaScript.【memoization】

324、Why is it called a Ternary statement, what does the word "Ternary" indicate?【三元语句】

325、What is the arity of a function?【参数数量】

326、~~3;What value is returned from the above statement?【位运算】

【JOB INTERVIEW QUESTIONNAIRE:jQuery-Specific Questions】

327、Explain "chaining".

328、Explain "deferreds".

329、What are some jQuery specific optimizations you can implement?

330、What does .end() do?

331、How, and why, would you namespace a bound event handler?

332、Name 4 different values you can pass to the jQuery method.

333、What is the effects (or fx) queue?

334、What is the difference between .get() and .eq()?

335、What is the difference between .bind(), .live(), and .delegate()?

336、What is the difference between $ and $.fn? Or just what is $.fn.

337、Optimize this selector:

【Front-End Dev Interview Questions】

338、What are namespaces? Give an example.

339、When you write your JavaScript, do you choose functional programming or object oriented?

340、Describe how you would make a JavaScript object. How would you call a function inside of it that accesses a property of that object?

341、When would you use a JavaScript animation over CSS3 Animations? Explain why.

342、How would you design a large scale project with JavaScript?

343、Explain what happens when you make an AJAX request?

344、What happens when you use var?

345、How would you assign Child Specific Objects?

【JavaScript questions】

相关文章
|
19天前
|
前端开发 JavaScript 网络协议
前端最常见的JS面试题大全
【4月更文挑战第3天】前端最常见的JS面试题大全
41 5
|
3月前
|
设计模式 前端开发 算法
No210.精选前端面试题,享受每天的挑战和学习
No210.精选前端面试题,享受每天的挑战和学习
No210.精选前端面试题,享受每天的挑战和学习
|
3月前
|
消息中间件 缓存 前端开发
No209.精选前端面试题,享受每天的挑战和学习
No209.精选前端面试题,享受每天的挑战和学习
No209.精选前端面试题,享受每天的挑战和学习
|
3月前
|
前端开发 JavaScript Java
No208.精选前端面试题,享受每天的挑战和学习
No208.精选前端面试题,享受每天的挑战和学习
No208.精选前端面试题,享受每天的挑战和学习
|
1月前
|
存储 缓存 监控
2024年春招小红书前端实习面试题分享
春招已经拉开帷幕啦! 春招的拉开,意味着新一轮的求职大战已经打响,希望每位求职者都能充分准备,以最佳的状态迎接挑战,找到心仪的工作,开启职业生涯的新篇章。祝愿每位求职者都能收获满满,前程似锦!
72 3
|
1月前
|
前端开发 数据可视化 安全
2024金三银四必看前端面试题!简答版精品!
2024金三银四必看前端面试题!2w字精品!简答版 金三银四黄金期来了 想要跳槽的小伙伴快来看啊
85 3
|
2月前
|
存储 前端开发 JavaScript
前端面试:如何实现并发请求数量控制?
前端面试:如何实现并发请求数量控制?
84 0
|
3月前
|
前端开发 JavaScript 数据处理
No207.精选前端面试题,享受每天的挑战和学习
No207.精选前端面试题,享受每天的挑战和学习
No207.精选前端面试题,享受每天的挑战和学习
|
8月前
|
Web App开发 前端开发 JavaScript
前端学习笔记202307学习笔记第五十七天-模拟面试笔记react-fiber解决了什么问题
前端学习笔记202307学习笔记第五十七天-模拟面试笔记react-fiber解决了什么问题
95 0
|
8月前
|
前端开发 定位技术
前端学习笔记202305学习笔记第二十三天-地图单线程配置
前端学习笔记202305学习笔记第二十三天-地图单线程配置
64 0
前端学习笔记202305学习笔记第二十三天-地图单线程配置