Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

诺诺网面试题 #9

Open
include-all opened this issue May 7, 2020 · 0 comments
Open

诺诺网面试题 #9

include-all opened this issue May 7, 2020 · 0 comments

Comments

@include-all
Copy link
Owner

include-all commented May 7, 2020

诺诺网面试题

1.怎么处理小数及大数计算的精度问题?

JavaScript数字精度丢失问题总结
JavaScript 里最大的安全的整数为什么是2的53次方减一?
精度丢失问题-看这篇文章就够了(通俗易懂)
第三篇文章把精度丢失的原理讲的很明白,有关符号位指数和尾数的原理

js存在精度丢失问题,因为计算机是二进制存储的,有些数字无法准确表示

  1. 浮点数精度问题
    0.1 + 0.2 === 0.30000000000000004 //true
    通过计算两个小数,乘10的幂次,之后再除以相同的10的幂次
    解决js运算精度丢失问题
  1. 大数精度问题
    精确的大数是Math.pow(2, 53) - 1,会造成9007199254740993 === 9007199254740993 //true
  1. toFixed问题
    1.335.toFixed(2)结果为1.33
    /**
     * 重写toFixed去解决
     * @param num  数字
     * @param s    保留位数
     * @returns {string}
     */
    function toFixed(num, s) {
        var times = Math.pow(10, s);
        var adjust = num > 0 ? 0.5 : -0.5;  //0.5是手动算四舍五入
        var des = num * times + adjust;
        des = parseInt(des, 10) / times;
        return des.toString();
    }

2. 垂直水平居中方法

一劳永逸的搞定 flex 布局
文章开头就是三种垂直居中的方法,注意margin负值的可以修改为下面代码(可以不用知道长宽):

.son{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

3. 请求的content-type区别?

application/json和application/x-www-form-urlencoded区别

4. ie8有哪些兼容性问题?

function trim(str){  
    return str.replace(/(^\s*)|(\s*$)/g, ""); 
}

5. ie9有哪些兼容性问题?不兼容placeholder,怎么解决?

简单实现IE9及以下对placeholder的兼容性

6. 怎么上传文件的?ie8下又该如何?

webuploader

7. HTML5有哪些新特性?CSS3呢?

HTML5和CSS3新特性一览

8. 怎么解决跨域?

招银网络面试题 14题

9. 用过哪些前端性能优化?

招银网络面试题 15题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant