在 JavaScript 中使用构造函数创建字符串对象?
要在 JavaScript 中创建字符串对象,请使用 string.constructor。构造函数返回对创建实例的原型的字符串函数的引用。
示例
你可以尝试运行以下代码,使用构造函数创建一个字符串对象 −
<html>
<head>
<title>JavaScript String constructor Method</title>
</head>
<body>
<script>
var str = new String( "This is string" );
document.write("str.constructor is:" + str.constructor);
</script>
</body>
</html>
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP