![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
题目
前端同学
学习为主,兴趣为辅,致力于向前端更深层次发展。
展开
-
哔哩哔哩:JS 异步笔试题
引入var date = new Date() console.log(1, new Date() - date) setTimeout(() => { console.log(2, new Date() - date)}, 500) Promise.resolve().then(console.log(3, new Date() - date)) while(new Date() - date < 1000) {} console.log(4, new Date原创 2021-08-18 13:35:26 · 280 阅读 · 0 评论 -
js通过模板字符串调用的函数,参数值解析
输出是什么?function getPersonInfo(one, two, three) { console.log(one) console.log(two) console.log(three)}const person = 'Lydia'const age = 21getPersonInfo`${person} is ${age} years old`输出是 ["", " is “, " years old”] “Lydia” 21如果使用标记模板字面量,第一个参数的原创 2021-05-07 17:08:01 · 1735 阅读 · 2 评论 -
js对象的键值
对象的键值只能是字符串或者是数字,如果不是的话,会默认调用tostring进行转const a = {}const b = { key: 'b' }const c = { key: 'c' }a[b] = 123a[c] = 456console.log(a[b]) //456对象的键被自动转换为字符串。我们试图将一个对象 b 设置为对象 a 的键,且相应的值为 123。然而,当字符串化一个对象时,它会变成 “[object Object]”。因此这里说的是,a["[objec原创 2021-05-07 16:00:21 · 2704 阅读 · 0 评论 -
delete操作符的使用细节
输出是什么?const name = "Lydia";age = 21;console.log(delete name);console.log(delete age);A: false, trueB: “Lydia”, 21C: true, trueD: undefined, undefined答案: Adelete操作符返回一个布尔值:true指删除成功,否则返回false. 但是通过 var, const 或 let 关键字声明的变量无法用 delete 操作符来删除。原创 2021-05-07 10:31:52 · 254 阅读 · 0 评论 -
JS对象属性writable、enumerable、configurable
输出是什么?const person = { name: "Lydia" };Object.defineProperty(person, "age", { value: 21 });console.log(person);console.log(Object.keys(person));A: { name: “Lydia”, age: 21 }, [“name”, “age”]B: { name: “Lydia”, age: 21 }, [“name”]C: { name: “Lydia原创 2021-05-06 20:11:31 · 1764 阅读 · 0 评论 -
你不知道的JSON.stringify
输出是什么?const settings = { username: "lydiahallie", level: 19, health: 90};const data = JSON.stringify(settings, ["level", "health"]);console.log(data);A: “{“level”:19, “health”:90}”B: “{“username”: “lydiahallie”}”C: “[“level”, “health”]”D: “原创 2021-05-06 19:24:48 · 83 阅读 · 0 评论 -
js函数参数值的引用问题
输出什么?const value = { number: 10 };const multiply = (x = { ...value }) => { console.log(x.number *= 2);};multiply();multiply();multiply(value);multiply(value);A: 20, 40, 80, 160B: 20, 40, 20, 40C: 20, 20, 20, 40D: NaN, NaN, 20, 40参数为空 x原创 2021-05-06 18:44:16 · 397 阅读 · 0 评论 -
import的坑
输出什么?// index.jsconsole.log('running index.js');import { sum } from './sum.js';console.log(sum(1, 2));// sum.jsconsole.log('running sum.js');export const sum = (a, b) => a + b;A: running index.js, running sum.js, 3B: running sum.js, running原创 2021-05-06 18:06:30 · 138 阅读 · 0 评论