avatar
Articles
25
Tags
1
Categories
0
Home
Archives
Huck's dev blog
Search
Home
Archives

Huck's dev blog

Implementing the apply Function Manually
Created2024-02-26
Steps to implement the apply function: Determine if the calling object is a function. Even though it’s defined on the function’s prototype, there may be instances where it is invoked using methods like call. Check if the incoming context object exists; if not, set it to window. Assign the function as a property of the context object. Determine if the parameter values have been passed in. Invoke the method using the context object and save the returned result. Remove the property that...
Flatten the array
Created2024-02-05
(1) Recursive implementationThe common idea behind recursion is straightforward, involving a circular recursion approach where each item is iterated over. If an item is still an array, the process continues recursively to achieve the concatenation of each array item. 1234567891011121314let arr = [1, [2, [3, 4, 5]]];function flatten(arr) { let result = []; for(let i = 0; i < arr.length; i++) { if(Array.isArray(arr[i])) { result = result.concat(flatten(arr[i]));...
Implement deep copy
Created2024-02-05
○ Shallow copy: Shallow copy refers to copying the attribute value of one object to another object. If the attribute value is a reference type, then the address of the reference is copied to the object, so the two objects will have a reference of the same reference type. Shallow copying can be implemented using Object.assign() and the spread operator. ○ Deep copy: Compared to shallow copy, if a property value is a reference type, deep copy creates a reference type and copies the...
What is the purpose of the newly added primitive data type "Symbol"?
Created2024-01-28
Discuss conceptual questions‘Symbol’ is a primitive data type introduced in ES6. Its primary purpose is to create a unique identifier, which is used in scenarios such as naming object properties, defining constants, and so on. Understanding with Examples Each ‘Symbol’ is unique and can be used as a property name for objects, which helps to avoid conflicts with property names. For example: 1234567const s1 = Symbol();const s2 = Symbol();const obj = { [s1]: 'hello', [s2]:...
What are the differences in asynchronous loading of JS scripts?
Created2024-01-28
What are the differences in asynchronous loading of JS scripts?In Web applications, the asynchronous loading of JavaScript scripts can be achieved in the following ways: a. Dynamically create a tag and set its src attribute to the URL of the script to be loaded. You can use the onload or onreadystatechange event to check if the script has finished loading. 123456const script = document.createElement('script');script.src = 'path/to/script.js';script.onload = function()...
Why is the result of 'typeof null' an 'object'?
Created2024-01-21
Why is the result of ‘typeof null’ an ‘object’?KernelThe result of ‘typeof null’ being “object” is a legacy issue of the JavaScript language. In the original version of JavaScript, a 32-bit value was used to represent a variable, with the first 3 bits representing the type of the value. 000 represents an object, 010 represents a floating point number, 100 represents a string, 110 represents a Boolean value, and other values are all considered pointers. In this representation, null was...
What are the uses of 'requestAnimationFrame' and 'requestIdleCallback', respectively?
Created2024-01-21
‘RequestAnimationFrame’ and ‘requestIdleCallback’ are both APIs used for performing animations or other high-performance tasks in the browser. ‘RequestAnimationFrame’ is a mechanism provided by browsers to request an animation frame. It executes a specified callback function right before the browser’s next redraw. The advantage of this approach is that it allows the browser to automatically perform complex calculations and rendering tasks during the next draw, thus preventing the browser...
Differences among Ajax, axios, and fetch
Created2024-01-14
(1)AJAXAjax stands for “Asynchronous JavaScript and XML.” It’s a way to make web pages interactive without reloading the whole page. Ajax updates parts of a page by fetching a bit of data from the server behind the scenes. This means updates can happen without a full page refresh. Traditional web pages without Ajax need a full reload to update. However, Ajax is not perfect: ● It’s more suited for MVC programming, not quite in line with the front-end MVVM trend. ● Built on the not-so-clear...
Understanding the execution context
Created2024-01-14
Execution context type (1)global execution context Anything that is not inside a function is a global execution context. It first creates a global window object and sets the value of this object to be equal to this global object. A program has only one global execution context. (2)function execution context When a function is called, a new execution context is created for the function. The context of the function can be as many as possible. (3)* * eval * * function execution context ...
The understanding of array-like objects
Created2024-01-14
1、The understanding of array-like objects ,and How to convert them into arrays?An object with the length attribute and several Index attributes can be called a array-like object. Array-like objects are similar to arrays, but array methods cannot be called. Common array-like objects include arguments and DOM methods. Function parameters can also be considered as array-like objects because they contain the length attribute value, which represents the number of parameters that can be received....
123
avatar
huck@love
Articles
25
Tags
1
Categories
0
Follow Me
Announcement
This is my Blog
Recent Posts
enable CORS support in Chrome on Mac2025-05-02
npm install config2025-02-20
Tapbit 合约页面性能报告2025-01-06
Performance Report for Tapbit BTC Contract Page2025-01-03
How large should a JS file be2025-01-02
Tags
CORS, Chrome, macOS, Web Development
Archives
  • May 2025 1
  • February 2025 1
  • January 2025 3
  • November 2024 4
  • March 2024 1
  • February 2024 3
  • January 2024 12
Website Info
Article Count :
25
Unique Visitors :
Page Views :
Last Update :
©2019 - 2025 By huck@love
Framework Hexo|Theme Butterfly
Search
Loading Database