摘要: 1. var lowerCaseOnly = /^[a-z]+$/; [lowerCaseOnly.test(null), lowerCaseOnly.test()] 答案:有关正则表达式,test过程会将传入的变量自动转换为字符串 null-》"null",完全没有则会转换为"undefined" 阅读全文
posted @ 2017-08-08 10:56 tong24 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1. var f = true; if (f true) { var a = 10; } function fn() { var b = 20; c = 30; } fn(); console.log(a); console.log(b); console.log(c); 2. var x = 1; 阅读全文
posted @ 2017-08-08 10:55 tong24 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1. []==[] 答案:false. 数组,在 Javascript 中是对象,对象使用 == 比较都是比较的引用。 简单的说,就是,如果是同一个对象,就相等,如果不是同一个对象,就不等。 每次使用 [] 都是新建一个数组对象,所以 [] == [] 这个语句里建了两个数据对象,它们不等。 2. 阅读全文
posted @ 2017-08-08 10:55 tong24 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 1. function() { var a = 10; if(a > 5) { a = 7; } alert(a); } 2. function() { if(true) { var a = 5; } alert(a); } 3. var a = 5; function first() { a = 阅读全文
posted @ 2017-08-08 10:54 tong24 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 1. var foo = function foo() { console.log(foo foo); }; foo(); 2. Number("1") - 1 == 0; 3. (true + false) > 2 + true; 4. function bar() { return foo; f 阅读全文
posted @ 2017-08-08 10:53 tong24 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1 (function(){ return typeof arguments; })(); 答案:object 知识点:typeof返回的六种类型,boolean,object,undefined,string,number,function(追问:typeof null 输出) arguments 阅读全文
posted @ 2017-08-08 10:47 tong24 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 1. (function(x, f = () => x) { var x; var y = x; x = 2; return [x, y, f()]; })(1) 2. (function() { return [ (() => this.x).bind({ x: 'inner' })(), (() 阅读全文
posted @ 2017-08-08 10:46 tong24 阅读(397) 评论(0) 推荐(0) 编辑
摘要: 1.输出结果和原因 console.log(a); // undefined console.log(b); // b is not defined window.b = 10; var a = 20; 2.函数表达式和函数声明的特点。 如果不声明函数名称,一定是表达式 ;如果声明名称,要通过上下文 阅读全文
posted @ 2017-08-08 10:42 tong24 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 1.两个function区别 function foo1() { return { // 返回对象{}留有一个大括号跟return在同一行 bar: "hello" }; } function foo2() { return { // {}没跟return同一行,所以返回的是undefined ba 阅读全文
posted @ 2017-08-08 10:41 tong24 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 题目: A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits. For example, take 153 (3 d 阅读全文
posted @ 2017-08-07 09:19 tong24 阅读(249) 评论(0) 推荐(0) 编辑