codecamp

Lodash _.parseInt

_.parseInt(string, [radix=10]) 

转换string字符串为指定基数的整数。 如果基数是 undefined 或者 0,则radix基数默认是10,如果string字符串是16进制,则radix基数为 16。注意: 这个方法与ES5 implementation 的 parseInt是一样的。

添加版本

1.1.0

参数

  1. string (string): 要转换的字符串。
  2. [radix=10] (number):转换基数。

返回

(number): 返回转换后的整数。

例子

_.parseInt('08');
// => 8 
_.map(['6', '08', '10'],
 _.parseInt);
// => [6, 8, 10]


Lodash _.padStart
Lodash _.repeat
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Lodash 简介

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }