New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2021-06-07 #9
Comments
English Review |
TipJS 判断类型的基本情况虽然现在大家都推崇用 typescript ,但是仍旧有不少被 js 当中的类型所困惑的,最主要的原因是 js 是动态的,类型可以是被改变的,导致我们需要去检查类型。 数据类型(Data Types)6种数据类型(2021年)分为 typeof undefined === "undefined" // undefined
typeof true === "boolean" // Boolean
typeof 123 === "number" // Number
typeof "123" === "string" // String
typeof 123n === "bigint" // BigInt
typeof Symbol('foo') === "symbol" // Symbol 结构类型(Structural Types)2种结构类型,分为 typeof console.log === "function" // Function 结构元类型(Structural Root)就是 null === null // null 现在基本讨论清楚基本类型的判断,现在还有一个 Object 该如何去处理。 Object一般地,判断它是不是 object !== null && typeof object === "object" 这是满足最初的要求。通常我们更需要它更为具体,比如我需要一个日期对象
好像是可以,这样的区分普通对象和 const fakeDate = {};
fakeDate[Symbol.toStringTag] = "Date" 然后我们就不太能区分了: Object.prototype.toString.call(new Date()) // "[object Date]"
Object.prototype.toString.call(fakeDate) // "[object Date]" 甚至可以被修改: const date = new Date()
Object.prototype.toString.call(date) // "[object Date]"
date[Symbol.toStringTag]="FakeDate"
Object.prototype.toString.call(date) // "[object FakeDate]" 这样显得 好吧,判断基本类型其实也差不多了,还有类似判断它是不是一个整数(isInteger)之类的也有点麻烦,我主要想记录 |
Share好玩
工具使用
端午节 |
|
Algorithm
最大子列和(Maximum Subarray 53)
这个题目挺经典的,当然我第一次就没想出来,因为如果你要暴力法那么整个复杂度是
O(n3)
这是不能接受的。后来我发现我想的太多了,如果从整体来看这个题目就好弄的多,把之前的走过的当作一整个部分。这个讲解推荐 《浙江大学数据结构》陈越老师的讲解,我很久之前听过这个,讲的让我感觉到对数据结构这门课程有了新的理解,推荐。
代码看起来就是非常简单的,其中的思想其实不是那么好懂,因为这是一个动态规划问题,如果你之前没有接触,那么你可能会被思维所限制。
The text was updated successfully, but these errors were encountered: