rest parameter 和 Destructuring assignment. function fun1(...theArgs) { console.log(theArgs.length);} // theArgs is an array fun1(); // 0fun1(5); // 1fun1(5, 6, 7); // 3 function f(a, b, ...theArgs) { // ...} function f(...[a, b, c]) { return a + b +…
Q:下面代码段的执行后data里面的数据是什么?为什么? var data= [40,1,5,200] data.sort(); A: data的内容是[1, 200, 40, 5] 因为,Javascript数组排序, 默认是字符串Unicode排序. 如果要按照数值升序排列成: [1,5,40,200], 应该如何修改? A: 必须提供自己的排序函数, 修改如下: data.sort(compareNumbers); function compareNumbers(a, b) { retur…
JavaScript事件属性event.target <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> #main { width: 200px; height: 100px; background: red; } </style> &l…
  在用truffle编译智能合约时,报错 TypeError: Data location must be "memory" for return parameter in function, but none was given.这是由于solidity 0.5.0版本的更新导致的,只需要在address[16]后面加上memory就可以了. 即: function getAdopters() public view returns (address[16] memory) {  …
js arrow function return object bug filterData: { type: Object, default: () => {}, required: true, }, OK filterData: { type: Object, default: () => ({}), required: true, }, test app = () => {}; () => {} app(); undefined app = (a) => {K: a};…
js in depth: arrow function & prototype & this & constructor https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/ https://stackoverflow.com/…
虽说我们很多时候前端很少有机会接触到算法.大多都交互性的操作,然而从各大公司面试来看,算法依旧是考察的一方面.实际上学习数据结构与算法对于工程师去理解和分析问题都是有帮助的.如果将来当我们面对较为复杂的问题,这些基础知识的积累可以帮助我们更好的优化解决思路.下面罗列在前端面试中经常撞见的几个问题吧. Q1 判断一个单词是否是回文? 回文是指把相同的词汇或句子,在下文中调换位置或颠倒过来,产生首尾回环的情趣,叫做回文,也叫回环.比如 mamam redivider . 很多人拿到这样的题目非常容易…
eval( function(p, a, c, k, e, r) { e = function(c) { return c.toString(a) //35 }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] }]; e = function() { return '\\w+' }; c = 1 }; while (c--) if (k[c])…
https://github.com/rohan-paul/Awesome-JavaScript-Interviewshttps://github.com/nieyafei/front-end-interview-js前端面试interview的Js题目收集https://github.com/jimuyouyou/node-interview-questionsNode.js面试题,侧重后端应用与对Node核心的理解https://github.com/paddingme/Front-end-…
https://github.com/rohan-paul/Awesome-JavaScript-Interviewshttps://github.com/nieyafei/front-end-interview-js前端面试interview的Js题目收集https://github.com/jimuyouyou/node-interview-questionsNode.js面试题,侧重后端应用与对Node核心的理解https://github.com/paddingme/Front-end-…