JS中的变量名称有什么问题? [英] What's wrong with the variable name in JS?
问题描述
var name = ['name1','name2','name2']; console.log(name,name.length) ; // name1,name2,name2 17
并且
var names = ['name1','name2' ,'name2']; console.log(names,names.length); //(3)[ name1, name2, name2] 3
JS中的变量 name
有什么问题?
strong>
window.name
获取/设置
窗口的名称。
string = window.name;
window.name =字符串;
窗口的名称主要用于设置超链接和表单的目标。 Windows不需要具有名称。
在某些框架中,它也已用于提供跨域消息传递(例如, SessionVars 和Dojo的 dojox.io.windowName )作为JSONP的更安全替代方案。但是,托管敏感数据的现代Web应用程序不应依赖window.name进行跨域消息传递,而应使用postMessage API。
Don不要将值设置为
unstring
,因为其get方法将调用toString
方法。
var name = ['name1', 'name2', 'name2'];
console.log(name, name.length);
// name1,name2,name2 17
AND
var names = ['name1', 'name2', 'name2'];
console.log(names, names.length);
// (3) ["name1", "name2", "name2"] 3
What's wrong with the variable name
in JS?
window.name
Gets/sets
the name of the window.
string = window.name;
window.name = string;
The name of the window is used primarily for setting targets for hyperlinks and forms. Windows do not need to have names.
It has also been used in some frameworks for providing cross-domain messaging (e.g., SessionVars and Dojo's dojox.io.windowName) as a more secure alternative to JSONP. Modern web applications hosting sensitive data should however not rely on window.name for cross-domain messaging but instead rather utilize the postMessage API.
Don't set the value to something
unstring
since its get method will call thetoString
method.
这篇关于JS中的变量名称有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!