diff --git a/vlib/builtin/js/string.js.v b/vlib/builtin/js/string.js.v index 3b72a2f6f4..ad54e449f1 100644 --- a/vlib/builtin/js/string.js.v +++ b/vlib/builtin/js/string.js.v @@ -205,7 +205,11 @@ pub fn (s string) hash() int { // int returns the value of the string as an integer `'1'.int() == 1`. pub fn (s string) int() int { - return int(JS.parseInt(s.str)) + res := int(0) + #if (typeof(s) == "string") { res.val = parseInt(s) } + #else { res.val = parseInt(s.str) } + + return res } // i64 returns the value of the string as i64 `'1'.i64() == i64(1)`.