js octal number All In One
js octal number All In One
const user = {
name: "Hayes",
id: 0,
};
interface User {
name: string;
id: number;
};
const user1: User = {
name: "Eric",
id: 0o7,
// id: 007,
};
/*
Octal literals are not allowed in strict mode.ts(1121)
Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o7'.ts(1085)
*/
const user2: User = {
name: "Eric",
id: '007',
};
/*
Type 'string' is not assignable to type 'number'.ts(2322)
defined-types.ts(9, 3): The expected type comes from property 'id' which is declared here on type 'User'
*/
Octal number (0o)
// ES-old
var n = 0755;
// 493
var m = 0644;
// 420
// ES2015 / ES6
var a = 0o10;
// 8
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates#octal_numbers
Hexadecimal number (0X / 0x)
0xFFFFFFFFFFFFFFFFF // 295147905179352830000
0x123456789ABCDEF // 81985529216486900
0XA // 10
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates#hexadecimal_numbers
refs
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates
http://www.javascripter.net/faq/octalsan.htm
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14928206.html
未经授权禁止转载,违者必究!