Javascript type conversion,
String to numeric: parseint ();
Converts a string to a floating point decimal point: parsefloat ();
During JSON data processing, the application needs to convert the string type to the object type.
Although string itself belongs to the object type, it can be used directly in theoretical classes.
However, in actual operations, it is unfortunate that it does not work.
No way. JSON data can be processed correctly only when the string type is converted to the object type.
// String convert to object function
// The string is forcibly converted to the object type
// String to object type
// The JSON parameter is a JSON string, which must be converted before JSON data can be correctly processed
VaR stringtoobject = function (JSON ){
Return eval ("(" + JSON + ")");
}
-- Use JavaScript code to implement zero padding,
-- For example, pad (125, 5) => 00125 /* Simple persistent Storage Method */
Function pad (Num, n ){
VaR Len = num. tostring (). length;
While (LEN <n ){
Num = "0" + num;
Len ++;
}
Return num;
}
--
-- Disable firebug
I believe no one knows what firebug is, but sometimes our bad code doesn't want our peers to easily use F12. So what should we do?
Here is a tricky way to help you achieve this.
If (window. Console & window. Console. firebug ){
Document. Body. innerhtml = '';
}
If you still don't think it's safe, you cannot even use F12.
Document. onkeydown = function (e ){
If (123 = (E | |{}). keycode) return false;
}
Oh, no one has read our code!
--
The demand is always reasonable and strange.