经典试题

// 第一题
(function () { var a = b = 5; })();
// 以下语句会输出什么
console.log(a); console.log(b);
// 第二题
// 以下代码会输出什么
var name = 'World!'; (function () {
if (typeof name === 'undefined') {
var name = 'Jack';
console.log('Goodbye ' + name);
} else {
console.log('Hello ' + name);
} })();
// 第三题
// 实现如下函数: 去除一个字符串的前后空白字符
' a '.trim(); // => 'a'
// 第四题
// 利用原生 console.log 实现如下函数
// log('hello', 'world'); // => '(app) hello world' function log() {}
// 第五题
var fullname = 'Mickey Mouse';
var obj = {
fullname: 'Donald Duck', prop: {
fullname: 'Pluto Dog', getFullname: function () { return this.fullname;
}
}
};
// 使用 getFullname 函数 依次打印出
// Mickey Mouse
// Donald Duck
// Pluto Dog
// 第六题
// 判断参数是否是 Array
function isArray() {}
// 第七题
// 实现如下功能的函数
[1].concat2(2, [3, 4], 5); // => [1, 2, 3, 4, 5];
// 第八题
// 实现如下函数
// console.log(sum(2)(3)); // 5 function sum() {}
// 第九题
// 实现斐波那契数, 注意效率 (时间效率, 空间效率)
 
// fib(1) == 1 // fib(2) == 1 // fib(3) == 2
// fib(4) == 3
// 第十题
// 翻转一颗二叉树
/**
*   4
*   /
*   2 7
*   / /
*   1 3 6 9
*
*   ----->
*   4
*   /
*   7 2
*   / /
*   9 6 3 1
*
*/
// Definition for Node. function Node(val) { this.val = val; this.left = null; this.right = null;
} function reverse(root) {}
// 第十一题
/**
*   Merge two sorted linked lists and return it as a new list.
*   The new list should be made by splicing together the nodes of the first two lists.
*
*   Example:
*   Input: 1->2->4, 1->3->4
*   Output: 1->1->2->3->4->4
*/
// Definition for singly-linked list. function ListNode(val) { this.val = val; this.next = null;
}
// 实现合并链表的函数
var mergeTwoLists = function (l1, l2) {}
// 第十二题
// 如何获取当前页面中标签的种类
 

原文地址:https://www.cnblogs.com/mingweiyard/p/5670318.html