TypeScript 字符串 长度属性 返回字符串的长度。 示例 var uname = new String("Hello World") console.log(uname) console.log("Length "+uname.length) // returns the total number of characters // including whitespaceTypeScriptCopy 编译时,它将生成相同的JavaScript代码。 其输出如下所示- Hello World Length 11TypeScriptCopy