Python知识分享网 - 专业的Python学习网站 学Python,上Python222
typescript-handbook PDF 下载
发布于:2024-01-24 11:25:55

typescript-handbook  PDF 下载   图1







The Basics
Each and every value in JavaScript has a set of behaviors you can observe from running different
operations. That sounds abstract, but as a quick example, consider some operations we might run
on a variable named message .
// Accessing the property 'toLowerCase'
// on 'message' and then calling it
// Calling 'message'
If we break this down, the first runnable line of code accesses a property called toLowerCase and
then calls it. The second one tries to call message directly.
But assuming we don't know the value of message - and that's pretty common - we can't reliably
say what results we'll get from trying to run any of this code. The behavior of each operation
depends entirely on what value we had in the first place.
Is message callable?
Does it have a property called toLowerCase on it?
If it does, is toLowerCase even callable?
If both of these values are callable, what do they return?
The answers to these questions are usually things we keep in our heads when we write JavaScript,
and we have to hope we got all the details right.
Let's say message was defined in the following way.
const message = "Hello World!";
As you can probably guess, if we try to run message.toLowerCase() , we'll get the same string
only in lower-case.