In C# you could do something like this :
string typeName = typeof(int).FullName;
And the value of typeName
would be System.Int32
. (Refer this question for reference).
So, my question is, how can I achieve the same thing in JavaScript or TypeScript?
Please note that I do not want to get the type name from an object
, I only want to get it from a type just like the example code above.
在Javascript中,您可以使用
typeof variable_name
我刚刚发现Node.js中的type-name包可以解决此问题。
var typeName = 5;
so you can put a simple alert in javascript.
an example like,
alert(typeof typeName);
just it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.