js小练习

今天给大家分享一些js相关知识点的小练习,有兴趣的可以尝试去做一下

判断题 

  1. NaN是否属性Number类型

  2. typeof Array类型返回 "object"

  3. 1 === "1" 返回值为true

    • 否  考核 === 全等于 基础值类型 比较的是值和类型是否一致 对象 比较的内存地址
  4. "151" >= 16 返回值为

    • true
    • false 隐式类型转换 >= 会尽力把两边的数据 转为 数值进行大小比较 151 >= 16 true
  5. 0.1 + 0.2 === 0.3

    • true
    • false 小数精度丢失 console.log(0.1 + 0.2 === 0.3 ); false
  6. +function(){ console.log(1) }() 能否执行

    • true
    • false 立即执行函数 +function(){console.log(1)}() 执行
  7. let a = {b:1} ; let b = { b: 1}; a == b 值为

    • true
    • false 对象存储地址  let a = {b:1} ; let b = { b:1}; console.log( a == b); // 对象 比较的内存地址 console.log(window.parseFloat === Number.parseFloat); 拿的同一个对象地址
  8. false || true && false 返回值

    • true
    • false || && 运算优先 && 优先于|| && 过真留假 || 过假留真 都假则留后面这个
  9. Boolean(0) 值为

    • true
    • false 布尔数据类型转化
  10. break作用: 停止或跳出当前循环;

    • true
    • false
  11. continue'作用: 跳过此次循环进入下次循环

    • true
    • false
  12. if(true){ let i = 10 } console.log( i ) // 打印 10

    • true
    • false 考核id 和 作用域 外层作用域无法访问局部作用域下的变量
  13. let arr = [1,2,3,4,5]; arr.pop(); arr[5] == 4 值为

    • true
    • false 访问数组内 没有的数据 返回undefined    arr.pop(); 删除数组末尾数组项
  14. let str = 'indexOf'; str.includes("index") 值为

    • true
    • false 字符串 includes(参数) 方法 判断参数是否在目标字符串中 在true 不在false
  15. Array.isArray([ ]) 返回值

    • true
    • false 判断参数是否是数组对象
  16. let obj = { 0: "a",1: "b",2: "c",length: 3},使用Array.from(obj);能转换成数组嘛?

    • true
    • false 获取一个数据类型 转另一个数据类型 原数据是不会改变的
  17. 函数的this永远指向window对象, 对吗

    • true
    • false this指向 函数名() this 指向 window 对象.属性名() this 指向对象 function fn(){ console.log(this); } fn() let obj = { // fn:fn fn } obj.fn()
  18. +'123' === 123 的值为

    • true
    • false 隐式类型转换 + 当一元操作符使用时 会尽力把一方数据 转为 数值型
  19. NaN === NaN 的值为

    • true
    • false NaN === NaN 的值为 not a number NaN是不可能等于 NaN
  20. let fn = ()=>{} 的写法正确吗?

    • true
    • false 箭头函数 let fn = () => { }

选择题  

  1. let a = '456' - '123' a等于

    • '456123'
    • '333'
    • NaN
    • 333 隐式类型转换 - 把两侧数据 尽力转为数值
  2. Number(60) + parseInt(String( 0.6 )) 值为

    • '606'
    • '6006'
    • NaN
    • 60 60 + parseInt('0.6') parseInt 会把字符串转数值 parseInt('0.6') = 0 60 + 0 console.log(Number(60) + parseInt(String( 0.6 )) );
  3. Number([]) + 3 * "6" - 2 % 3 值为

    • 16
    • 1
    • NaN
    • 报错 隐式类型转换 大模小取余 小模大取小 运算符优先级 console.log(Number([]) + 3 * "6" - 2 % 3 ); 0 + 18 - 2 = 16
  4. let a = 10, b = 20; a + b++ 值为

    • 31
    • 30
    • 1020
    • 29 ++ 前置++ (先自增 然后再交值) 后置++ (先交值 然后再自增)
  5. let a = 0 ? "夏栀" : "师姐" || "Lisa" && "林允儿" ; a值为

    • "夏栀"
    • "师姐"
    • "Lisa"
    • "林允儿" 运算符优先级 三目运算 || && // let a = 0 ? "夏栀" : "师姐" || "Lisa" && "林允儿" ; // false 走 : "师姐" || "Lisa" && "林允儿" // "师姐" || "林允儿" // "师姐"
  6. let a = 100; function fun(a){ console.log(a) } fun() ; a打印值为

    • undefined
    • 100
    • 报错
    • a 作用域 let a = 100; function fun(a) { console.log(a) //undefined }; fun() let a = 100; function fun() { console.log(a) //100 }; fun()
  7. let a = "初始位置与终点位置"; console.log( a.substr(1,5) ) 打印

    • 始位置与终
    • 始位置与
    • 始位置与终点位置
    • 不打印 字符串 方法 substr(1,5) 第二个参数 是截取长度
  8. function fun(){ console.log(this) }; let obj = { a : fun}; obj.a(); this是?

    • obj
    • window
    • 报错
    • 不打印 this指向
  9. let [a,b,c = 3] = [true,false]; Boolean(c) 值为

    • true
    • false
    • 1
    • undefined 解构赋值 若// let [a,b,c] = [true,false]; // console.log(c); //undefined 作用域 就是变量生效的范围
  10. let { a:aa ,c:cc, b:bb} = {a:1,b:2,c:3} console.log(a,c,b) 为

    • 1 2 3
    • 1 3 2
    • 报错
    • aa cc bb 解构赋值 // let { a: aa, c: cc, b: bb } = { a: 1, b: 2, c: 3 } //实际上我们在声明 aa cc bb // console.log(a, c, b) // 未声明直接使用 报错
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值