Comments (4)
Out of curiosity, what's the use case for Object.create(null)
here? What are you doing with it in code?
from redux.
I use it just to create an empty object for storing data, and later I will add keys and values to this empty object. In some cases, it just makes it convenient for me to have fewer declarations, for example, declaring AnyObject explicitly.
const data = Object.create(null);
data.a = 1;
const data: AnyObject = {};
data.a = 1;
from redux.
@zhe-he : I'm okay with merging the fix, but tbh I'm not sure I see an actual reason to use Object.create(null)
here :) the AnyObject
example is actually shorter, and also more clear about what's going on.
from redux.
Well..., I'm not trying to convince you which method is better, I think any method is fine, it's just based on my personal habits.
I don't like explicit declarations, so I used the any returned by Object.create. At the same time, I personally think that the Object.create(null) loop will be a bit faster, so I used this, below is the time spent on testing.
// 2 lines
import { AnyObject } from "@/@types";
const data: AnyObject = {};
// 1 line
const data = Object.create(null);
// 2 lines or 9 lines
export type M = {
name: string;
value: string;
child?: M[];
}
export type O = {
[props: string]: M
}
// import { O } from "@/@types";
const map: O = {}
// 1 line
const map = Object.create(null);
from redux.
Related Issues (20)
- Math.random() usage HOT 3
- Instead of Why there should What HOT 1
- Missing link in Learning Resources -> Middleware
- updating redux from 5.0.0 to 5.0.1 Typescript errors HOT 18
- Could β plainβ class instances be stored in Redux store state. HOT 15
- Update copyright HOT 1
- Invalid external image link
- Small inconsistant in the docs: src/app/ or app/? HOT 2
- Redux core example app not working HOT 1
- Add combineSlices section to Code Splitting page
- doc not match in setup with nextjs HOT 1
- The wrong export in redux/examples/counter-ts/src/features/counter/counterSlice.ts HOT 1
- remove references to deprecated createStore
- Redux import type gone since upgrading to latest version with javascript (Next 14) HOT 5
- Should not set the useRef current value during rendering HOT 2
- Add first-party support for persistence to redux HOT 2
- Argument of type 'AsyncThunkAction<{ id: number; }, void, AsyncThunkConfig>' is not assignable to parameter of type 'UnknownAction'. HOT 1
- Include UMD build artifacts for latest release HOT 1
- [Docs] Normalizing State Shape: Normalizr no longer maintained HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux.