caoweiju / js_com_utils Goto Github PK
View Code? Open in Web Editor NEWJavaScript通用工具类函数集合
JavaScript通用工具类函数集合
很多时候前端的数据是通过接口来获取的,而数据也可能已经约定好了格式,
{
a:{
b:{
c:{
d: 'data'
}
}
}
}
有的时候我们理想的去读取a.b.c.d
,很有可能就会出现Cannot read property '*' of undefined
;
机灵的孩子来了 a && a.b && a.b.c && a.b.c.d
;很好,避免了上面的报错,不过可能会出现这样的情况
// 约定的数据
{
a:{
b:{
c:{
length: 20
}
}
}
}
// 返回的数据
{
a:{
b:{
c:[1, 2]
}
}
}
所以需要一个这样的方法来一层一层的正确读取对象的各个属性。
很多时候,我们前端通过restful
接口来获取了数据,先判断接口标识ret、status
{
msg: 'ok',
ret : true,
data:{
baseInfo:{},
isCurr: false,
dates: [],
tit: '',
subtit: null,
num: 0
}
}
我们抱着严谨的态度,都需要进行验证各类数据的真实性。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.