字节跳动面试题

console.log(([])?true:false); //true
console.log(([]==false?true:false));//true
console.log(({}==false)?true:false) ;//false

[ ]返回0
{ }返回NaN
布尔类型里只有这几个参数返回false,其它都为true
Boolean(undefined) // false
Boolean(null) // false
Boolean(0) // false
Boolean(NaN) // false
Boolean('') // false

  1. 行内元素<a> <b> <span> <img> <input> <select> <strong>
    块级元素(独占一行)<div> <ul> <ol> <li> <dl> <dt> <dd> <h1>...... <p>
    常见空元素<br> <hr> <img> <input> <link> <meta>
  2. javascript中实现跨域的方式总结
    jsonp请求:jsonp的原理是利用<script>标签的跨域特性,可以不受限制地从其他域中加载资源,类似的标签还有<img>.
    document.domain:这种方式用在主域名相同子域名不同的跨域访问中
    window.name:window的name属性有个特征:在一个窗口(window)的生命周期内,窗口载入的所有的页面都是共享一个window.name的,每个页面对window.name都有读写的权限,window.name是持久存在一个窗口载入过的所有页面中的,并不会因新页面的载入而进行重置。
    window.postMessage:window.postMessages是html5中实现跨域访问的一种新方式,可以使用它来向其它的window对象发送消息,无论这个window对象是属于同源或不同源。
    CORS:CORS背后的基本思想,就是使用自定义的HTTP头部让浏览器与服务器进行沟通,从而决定请求或响应是应该成功还是应该失败。
    Web Sockets:web sockets原理:在JS创建了web socket之后,会有一个HTTP请求发送到浏览器以发起连接。取得服务器响应后,建立的连接会使用HTTP升级从HTTP协议交换为web sockt协议。
  3. 不可继承的:display、margin、border、padding、background、height、min-height、max- height、width、min-width、max-width、overflow、position、left、right、top、 bottom、z-index、float、clear、table-layout、vertical-align、page-break-after、 page-bread-before和unicode-bidi。

所有元素可继承:visibility和cursor。

内联元素可继承:letter-spacing、word-spacing、white-space、line-height、color、font、 font-family、font-size、font-style、font-variant、font-weight、text- decoration、text-transform、direction。

块状元素可继承:text-indent和text-align。

列表元素可继承:list-style、list-style-type、list-style-position、list-style-image。

表格元素可继承:border-collapse

  1. ①get和post的可传输内容大小不一样,一个有限制一个没有限制
    ②get和post传输的内容存放的位置不一样,一个放在header,一个放在body
    ③get的 Content-type不仅可以是 text/html,也可以是其他,如 application/json, text/plain 等
    ④get请求和post请求都可以跨域
typeof String()    //"string"
typeof Number()    //"number"
typeof NaN 
typeof Object()    //"object"
typeof null        
typeof Array()
typeof Boolean()   //"boolean"
typeof undefined   //"undefined"
typeof Function()  //"function"
typeof Symbol()    //"symbol"
  1. ①visibility:hidden;所占据的空间位置仍然存在,仅为视觉上的完全透明
    ②display:none;不为被隐藏的对象保留其物理空间
  2. TCP


    图片.png
  3. <input id="btnShow" type="button" value="点击" class="btn">上面是一段按钮的html代码 如果要用原生的js来禁用这个按钮 可以用这样: document.getElementByIdx_x_x("btnShow").disabled=true;
    ②如果要重新开启按钮,则可以让disabled=false;
    ③利用jquery的attr的方法设置jquery$("#btnShow").attr({"disabled":"disabled"});
    ④让按钮恢复可用,可以采用removeAttr方法把disabled属性删除$("#btnShow").removeAttr("disabled");
  4. 选择器的优先级
    ①在属性后面使用 !important 会覆盖页面内任何位置定义的元素样式。
    ②作为style属性写在元素内的样式
    ③id选择器
    ④类选择器 = 伪类选择器=属性选择器
    ⑤标签选择器
    ⑥通配符选择器
    ⑦浏览器自定义的样式
图片.png
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    .container {
      display: flex;
      width: 180px;
      height: 180px;
      flex-wrap: wrap;
    }
    .box {
      width: 50px;
      height: 50px;
      border: 5px solid blue;
      background-color:aqua;
      text-align: center;
      line-height: 50px;
      margin-right: -5px;
    }
    .box:hover {
      border: 5px solid red;
      z-index:9999;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="box">1</div>
    <div class="box">2</div>
    <div class="box">3</div>
    <div class="box">4</div>
    <div class="box">5</div>
    <div class="box">6</div>
    <div class="box">7</div>
    <div class="box">8</div>
    <div class="box">9</div>
  </div>
</body>
</html>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容