- Jan 2, 2006
- 10,455
- 35
- 91
Really. It's such a pain in the ass if you're working 100% in JavaScript anyway.
If you're doing your entire stack in JS it would be SO nice to just be able to store everything in their original data types so you don't have to mess around with the data types when you retrieve them again.
Numbers instead of strings.
Ability to store functions.
Ability to store constructors ( new Date() ).
Right now if I have an object like:
it would be nice to just store it into my DB and maybe the user's browser localstorage just like that.
But instead everything needs to be a string and functions are forbidden.
When you retrieve the data again you have to do extra work to convert the items back into their intended data type, add the original functions back into the object, parse your own data, etc.
If you're doing your entire stack in JS it would be SO nice to just be able to store everything in their original data types so you don't have to mess around with the data types when you retrieve them again.
Numbers instead of strings.
Ability to store functions.
Ability to store constructors ( new Date() ).
Right now if I have an object like:
Code:
var myOrder = {
dateCreated: new Date();
items: [
// all items
],
totalPrice: function(){
// return the total price of everything using this.items in a loop
},
}
it would be nice to just store it into my DB and maybe the user's browser localstorage just like that.
But instead everything needs to be a string and functions are forbidden.
When you retrieve the data again you have to do extra work to convert the items back into their intended data type, add the original functions back into the object, parse your own data, etc.