zoukankan      html  css  js  c++  java
  • 看看国外的javascript题目,你能全部做对吗?

    叶小钗 的博客最近都在讨论面试题目

    正好以前也看过一篇,就借花献佛拿出来分享一下 http://perfectionkills.com/javascript-quiz/

    附带了自己的理解,答案有争议的地方欢迎大家指出

    题目一

    (function(){ 
      return typeof arguments; 
    })(); 
     答案

    题目二

    var f = function g(){ return 23; }; 
    typeof g();
    答案

    题目三

    (function(x){ 
      delete x; 
      return x; 
    })(1); 
     答案

    题目四

    var y = 1, x = y = typeof x; 
    x; 
     答案

    题目五

    (function f(f){ 
      return typeof f(); 
    })(function(){ return 1; }); 
     答案

    题目六

    var foo = {  
      bar: function() { return this.baz; },  
      baz: 1 
    }; 
    
    (function(){  
      return typeof arguments[0](); 
    })(foo.bar);
    答案

    题目七

    var foo = { 
      bar: function(){ return this.baz; }, 
      baz: 1 
    } 
    typeof (f = foo.bar)();
    答案
     

    题目八

    var f = (function f(){ return "1"; }, function g(){ return 2; })(); 
    typeof f;
    答案

    题目九

    var x = 1; 
    if (function f(){}) { 
      x += typeof f; 
    } 
    x;
    答案

    题目十

    (function f(){ 
      function f(){ return 1; } 
      return f(); 
      function f(){ return 2; } 
    })();
    答案

    题目十一

    function f(){ return f; } 
    new f() instanceof f;
    答案

    题目十二

      var x = [typeof x, typeof y][1];
      typeof typeof x;

    答案

    这题目比较简单,注意下返回类型即可
    x = [,][1];
    即 x = typeof y = 'undefind'.
    typeof 返回的是string类型就可以了 
    typeof typeof必然就是'string'了.
    View Code

    题目十三

    function(foo){ 
      return typeof foo.bar; 
    })({ foo: { bar: 1 } });
    答案

    题目十四

    with (function(x, undefined){}) length;
    答案
  • 相关阅读:
    JS分页条插件
    C#Lambda
    常用CSS样式速查
    简易表格编辑器
    使用template
    js 时间类函数
    数据库表增删查改帮助类
    使用github
    box-shadow属性
    box-sizing属性
  • 原文地址:https://www.cnblogs.com/aaronjs/p/3172112.html
Copyright © 2011-2022 走看看