someExperience
// 面试题1
var name = 'World';
(function () {
if (typeof name==='undefined') {
var name = 'jack';
console.log('Good bye' + name)
}else{
console.log('Hello' + name)
} })();
//Good byejack 答对了,变量提升 //
var str = 'hi';
console.log('Value' + (str==='hi')?'something':'nothing')//something //
var arr = [0,1,2];
arr[10] = 10;//[ 0, 1, 2, , , , , , , , 10 ]
var arr2 = arr.filter(function(x){
return x===undefined
});
console.log(arr2)//[] //
function showCase(value){
switch(value){
case 'A':
console.log('Case A');
break;
case 'B':
console.log('Case B');
break;
case 'C':
console.log('Case C');
break;
case 'D':
console.log('Case D');
break;
default:
console.log('unkonw')
}
}
showCase(new String('A'));//unkonw
console.log(new String('A'))//[String: 'A']
//
function isOdd(num){
return num%2 ==1;
}
function isEven(num){
return num%2 == 0;
}
function isSane(num){
return isEven(num) || isOdd(num)
}
var value = [7,4,'13',-9,Infinity];
var mapReruslt = value.map(isSane);
console.log(mapReruslt)//[ true, true, true, false, false ] //我的答案 true, true, false, false, false
//
console.log('5'+3);//
console.log('5'-3)// //
console.log(Array.prototype)//[]
console.log(Array.isArray(Array.prototype))//true 8
function sidEff(ary){
ary[0] = ary[2];
}
function bar(a,b,c){
c = 10;
sidEff(arguments);
return a+b+c
}
console.log(bar(1,1,1))//我的答案21结果是对的 function foo(a){
var a;
return a;
}
function bar(a){
var a = 'bye';
return a;
};
console.log([foo('hello'),bar('hello')])//[ 'hello', 'bye' ] //我的答案是undefined bye var a ={}; b =Object.prototype;
console.log(a.prototype === b,Object.getPrototypeOf(a)===b)//false true //我的答案true true
someExperience的更多相关文章
随机推荐
- 用EPOLL进行压力测试
在以前的博客中提到的一个服务端,在以前压力测试的过程中,发现单核CPU最多能达到1000TPS 还以为是服务端性能不够好,所以一直想着怎么去优化它. 但优化的思路明显不多,所以就考虑换一种压力测试的方 ...
- ubuntu 忘记用户名及密码解决办法
1.重启系统 2.长按Shift键,直到出现菜单.选择recovery mode,即恢复模式 3.选择root 4.# 后面敲入 cat /etc/shadow 查看用户名 5.# passwd & ...
- SQLite使用教程11 表达式
SQLite 表达式 表达式是一个或多个值.运算符和计算值的SQL函数的组合. SQL 表达式与公式类似,都写在查询语言中.您还可以使用特定的数据集来查询数据库. 语法 假设 SELECT 语句的基本 ...
- android studio简易了解第二部分
1.新建Moudle(eclispe的项目) 其余的和eclipse差不多,一般情况一直next就可以了! 如果选择New Project会重新打开一个AS.一个AS只会有一个Project(ecli ...
- jquery判断输入文字个数的统计代码
1.js代码部分 <script type="text/javascript"> $(function() { function albumNa ...
- iOS UICollectionView基础
转载自:http://www.cnblogs.com/wayne23/p/4013522.html 初始化部分: UICollectionViewFlowLayout *flowLayout= [[ ...
- Spring MVC page render时jsp中元素相对路径的解决办法
前段时间做了用Spring Security实现的登录和访问权限控制的功能,但是page render使用的是InternalResourceResolver,即在spring的servlet配置文件 ...
- careercup-中等难题
17.1 编写一个函数,不用临时变量,直接交换两函数. 解法: 方法一:这个是经典面试题,也相当直接.我们将用a0表示a的初值,b0表示b的初始值,用diff表示a0-b0的值. 让我们将a>b ...
- VM11安装Mac OS X 10.10
工具/原料 1. VMware Workstation 11.12 2. unlocker 206(for OS X 插件补丁) 3. Mac OS X 10.10镜像 方法/步骤 有图有真相,哈 ...
- (一)javascript中的数组index属性——获取数组的索引值
例如:要做到这样的效果 点击每个选项时,会显示不同的div. 我们的做法:在javascript中,先把所有的div的display设置为none,然后在根据当前的数组里的索引值进行一个显示div的过 ...