console中的%d %s等占位符
文章目录
前端开发中经常用到浏览器的console控制台,
而在console.log和console.debug中有时候可以看见%d %s这样的符号,其意义和用法如下
占位符含义
-
%sfor a String value 代表字符串 -
%d或%ifor a Integer value 代表整数 -
%ffor a Floating point number 代表浮点数 -
%ofor an Object hyperlink 代表对象的超链接
例子
var name = "David";
var num = 24;
var height = 180.5;
var obj = {
job: 'web developer',
};
console.log('%s is %d years old, and he is %fcm tall.\nMore details in: %o', name, num, height, obj);
参考
https://stackoverflow.com/que...
https://blog.csdn.net/linusc/...
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论