Skip to content

issues Search Results · repo:Advanced-Frontend/Daily-Interview-Question language:JavaScript

Filter by

562 results
 (100 ms)

562 results

inAdvanced-Frontend/Daily-Interview-Question (press backspace or delete to remove)

我使用Chrome打印为 { 2 : 1, 3 : 2, length : 4 } 分析: 1. push 方法的行为: Array.prototype.push 方法根据对象的 length 属性决定插入位置。调用 push 时,元素会被添加到索引 length 处,并将 length 加 1。 2. 第一次 push(1): 初始 length 为 2,元素 ...
  • wjc7jx
  • Opened 
    12 days ago
  • #593

const arr = [10, 21, 0, -7, 35, 7, 9, 23, 18] var pos = 0 var num = arr[0] for (var i = 1; i arr.length; i++) { if (arr[i] 0 arr[i] num) { num = arr[i] pos = i } } return pos
  • zhangzhangjing
  • Opened 
    12 days ago
  • #592

const fn = (num) = { const res = [] let i = 1 const temp = Math.ceil(num.toString().split( ).length / 2) let maxNum = Number(1${[...Array(temp).keys()].map(i = 0 ).join( )}) const reverseFn = (n) = n.toString().split( ...
  • yuewanxinghui
  • Opened 
    on Oct 21, 2024
  • #591

const fn = function(str){ let arr = str.split( ) let obj = {} let maxStr = , maxNum = 0; arr.reduce((pre, next) = { if(pre in obj){ if(pre == next) obj[pre]++ }else{ obj[pre] = 1 } return next },arr[0]) ...
  • DingSJi
  • Opened 
    on Aug 27, 2024
  • #590

` Object.prototype.map = function(callback){ if(typeof callback !== function ){ throw new TypeError( param must be a Function ) } const newObj = {} for(const key in this){ if(this.hasOwnProperty(key)){ ...
  • luo29
  • Opened 
    on Mar 29, 2024
  • #589

setTimeout 定时器,可以延迟执行,属于宏任务,在JavaScript事件循环中,执行优先级最低。 Promise 本身是同步的立即执行函数, 当在executor中执行resolve或者reject的时候, 此时是异步操作, 会先执行then/catch等,当主栈完成后,才会去调用resolve/reject中存放的方法执行,打印p的时候,是打印的返回结果,一个Promise实例。resolve函数的作用是,将Promise对象的状态从“未完成”变为“成功”(即从 ...
  • codewycat
  • Opened 
    on Aug 26, 2023
  • #588

var b = 10; (function b(){ b = 20; console.log(b); })(); 如下: var b = 10; (function b(){ var b = 20; console.log(b); })(); // 20 var b = 10; (function (){ var b = 20; console.log(b); })(); // 20 var ...
  • codewycat
  • Opened 
    on Aug 25, 2023
  • #587

这段代码会输出函数本身作为变量b的值,并不会被重新赋值为20。这是因为在自执行函数中中,函数的参数和内部局部变量会覆盖全局作用域中的同名变量。在这个自执行函数中,函数名b被定义为函数本身,并形成了一个闭包。当我们尝试将b重新赋值为20时,其实是在修改闭包中的局部变量,而不是全局变量b。因此,输出结果仍然是函数本身。
  • DarknessZY
  • Opened 
    on Jul 26, 2023
  • #586

就我的使用来说(Vue)key的作用是为了在数据变化时强制更新组件,以避免“原地复用”带来的副作用,官方文档也说明了**不带key性能更好**,见:[List Rendering - key](https://cn.vuejs.org/v2/guide/list.html#key) 我的理解是,vue和react虽然都采用了diff算法。 但是react本身的设计和vue的设计是截然不同的, ...
  • Bibooo25730
  • Opened 
    on Jun 4, 2023
  • #585
Issue origami icon

Learn how you can use GitHub Issues to plan and track your work.

Save views for sprints, backlogs, teams, or releases. Rank, sort, and filter issues to suit the occasion. The possibilities are endless.Learn more about GitHub Issues
ProTip! 
Press the
/
key to activate the search input again and adjust your query.
Issue origami icon

Learn how you can use GitHub Issues to plan and track your work.

Save views for sprints, backlogs, teams, or releases. Rank, sort, and filter issues to suit the occasion. The possibilities are endless.Learn more about GitHub Issues
ProTip! 
Press the
/
key to activate the search input again and adjust your query.
Issue search results · GitHub